Part Number Hot Search : 
4ALS10 1N4935 KBU4A04 EG200 BZX976V2 ENA1112 2SC3206 SC141
Product Description
Full Text Search
 

To Download UPSD3423E-40T6T Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1/264 preliminary data march 2005 this is preliminary information on a new product now in development or undergoing evaluation. details are subject to change wit hout notice. upsd34xx turbo plus series fast turbo 8032 mcu with usb and programmable logic rev 2.0 features summary fast 8-bit turbo 8032 mcu, 40mhz ? advanced core, 4-clocks per instruction ? 10 mips peak performance at 40mhz (5v) ? jtag debug and in-system programming ? 16-bit internal instruction path fetches double-byte instruction in a single memory cycle ? branch cache & 4 instruction prefetch queue ? dual xdata pointers with automatic increment and decrement ? compatible with 3rd party 8051 tools dual flash memories with memory management ? place either memory into 8032 program address space or data address space ? read-while-write operation for in- application progra mming and eeprom emulation ? single voltage program and erase ? 100k guaranteed erase cycles, 15-year retention clock, reset, and power supply management ? sram is battery backup capable ? flexible 8-level cpu clock divider register ? normal, idle, and power down modes ? power-on and low voltage reset supervisor ? programmable watchdog timer programmable logic, general purpose ? 16 macrocells for logi c applications (e.g., shifters, state machines, chip-selects, glue-logic to keypads, and lcds) a/d converter ? eight channels, 10-bit resolution, 6s figure 1. packages communication interfaces ? usb v2.0 full speed (12mbps) 10 endpoint pairs (in/out), each endpoint with 64-byte fifo (supports control, intr, and bulk transfer types) ?i 2 c master/slave controller, 833khz ? spi master controller, 1mhz ? two uarts with independent baud rate ? irda potocol: up to 115 kbaud ? up to 46 i/o, 5v tolerant upsd34xxv timers and interrupts ? three 8032 standard 16-bit timers ? programmable counter array (pca), six 16-bit modules for pwm, capcom, and timers ? 8/10/16-bit pwm operation ? 12 interrupt sources with two external interrupt pins operating voltage source (10%) ? 5v devices: 5.0v and 3.3v sources ? 3.3v devices: 3.3v source tqfp52 (t), 52-lead, thin, quad, flat tqfp80 (u), 80-lead, thin, quad, flat
upsd34xx - features summary 2/264 table 1. device summary note: operating temperature is in the industrial range (?40c to 85c). part number max mhz 1st flash (bytes) 2nd flash sram gpio 8032 bus v cc v dd pkg. upsd3422e-40t6 40 64k 32k 4k 35 no 3.3v 5.0v tqfp52 upsd3422ev-40t6 40 64k 32k 4k 35 no 3.3v 3.3v tqfp52 upsd3422e-40u6 40 64k 32k 4k 46 yes 3.3v 5.0v tqfp80 upsd3422ev-40u6 40 64k 32k 4k 46 yes 3.3v 3.3v tqfp80 upsd3433e-40t6 40 128k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3433ev-40t6 40 128k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3433e-40u6 40 128k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3433ev-40u6 40 128k 32k 8k 46 yes 3.3v 3.3v tqfp80 upsd3434e-40t6 40 256k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3434ev-40t6 40 256k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3434e-40u6 40 256k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3434ev-40u6 40 256k 32k 8k 46 yes 3.3v 3.3v tqfp80
3/264 upsd34xx - table of contents table of contents features summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 table of contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 summary description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 internal memory (mcu module, st andard 8032 memory: data, idata, sfr) . . . . . . . . . . . . 17 external memory (psd module: program memory, data memory). . . . . . . . . . . . . . . . . . . . . . 17 8032 mcu core performance enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 pre-fetch queue (pfq) and branch cache (bc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 pfq example, multi-cycle instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 aggregate performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 mcu module discription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 8032 mcu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 stack pointer (sp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 data pointer (dptr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 program counter (pc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 accumulator (acc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 b register (b). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 general purpose registers (r0 - r7). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3 program status word (psw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 special function registers (sfr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 8032 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 register addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 direct addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 register indirect addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 immediate addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 external direct addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 external indirect addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 indexed addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 relative addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 absolute addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 long addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 bit addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
upsd34xx - table of contents 4/264 upsd34xx instruction set summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 dual data pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 data pointer control register, dptc (85h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 data pointer mode register, dptm (86h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 debug unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 interrupt system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 individual interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 mcu clock generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 mcu_clk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 periph_clk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 power saving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 reduced frequency mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 oscillator and external components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 i/o ports of mcu module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 mcu port operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 mcu bus interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 psen bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 read or write bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 connecting external devices to the mcu bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 programmable bus timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 controlling the pfq and bc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 supervisory functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 external reset input pin, reset_in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 7 low v cc voltage detect, lvd. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 power-up reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 jtag debug reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 watchdog timer, wdt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 standard 8032 timer/counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 standard timer sfrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 sfr, tcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 sfr, tmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 timer 0 and timer 1 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5/264 upsd34xx - table of contents serial uart interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 uart operation modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 serial port control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 uart baud rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 more about uart mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 more about uart mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 more about uart modes 2 and 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 irda interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 baud rate selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 pulse width selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 i 2 c interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 i2c interface main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 communication flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 bus arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 clock synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 general call address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 serial i/o engine (sioe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 i 2 c interface control register (s1con) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 i 2 c interface status register (s1sta) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 i2c data shift register (s1dat). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 i 2 c address register (s1adr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 7 i 2 c start sample setting (s1setup) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 i 2 c operating sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 spi (synchronous peripheral interface) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 spi bus features and communication flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 full-duplex operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 bus-level activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 spi sfr registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 spi configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 dynamic control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 usb interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 basic usb concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 types of transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 endpoint fifos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 usb registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 typical connection to usb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 analog-to-digital convertor (adc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 port 1 adc channel selects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
upsd34xx - table of contents 6/264 programmable counter array (pca) with pwm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 pca block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 pca clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 operation of tcm modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 capture mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 timer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 toggle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 pwm mode - (x8), fixed frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 pwm mode - (x8), programmable frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 pwm mode - fixed frequency, 16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 pwm mode - fixed frequency, 10-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 writing to capture/compare registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 control register bit definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 tcm interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 psd module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 psd module functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 psd module data bus width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 runtime control register definitions (csiop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 psd module detailed operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 78 psd module reset conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 24 ac/dc parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 maximum rating. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 dc and ac parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 package mechanical information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 part numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 important notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 usb interrupts with idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 usb reset interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 usb reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 data toggle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 usb fifo accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 erroneous resend of data packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 in fifo pairing operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 port 1 not 5-volt io tolerant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 revision history. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
7/264 upsd34xx - summary description summary description the turbo plus upsd34xx series combines a powerful 8051-based microcontroller with a flexi- ble memory structure, programmable logic, and a rich peripheral mix to form an ideal embedded controller. at its core is a fast 4-cycle 8032 mcu with a 4-byte instruction prefetch queue (pfq) and a 4-entry fully associative branching cache (bc). the mcu is connected to a 16-bit internal instruc- tion path to maximize performance, enabling loops of code in smaller localities to execute extremely fast. the 16-bit wide in struction path in the turbo plus series allows double-byte instructions to be fetched from memory in a single memory cycle. this keeps the average performance near its peak performance (peak performance for 5v, 40mhz turbo plus upsd34xx is 10 mips for single-byte instructions, and averag e performance will be ap- proximately 9 mips for mix of single- and multi- byte instructions). usb 2.0 (full speed, 12mbps) is included, provid- ing 10 endpoints, each with its own 64-byte fifo to maintain high data throughput. endpoint 0 (con- trol endpoint) uses two of the 10 endpoints for in and out directions, the remaining eight endpoints may be allocated in any mix to either type of trans- fers: bulk or interrupt. code development is easily managed without a hardware in-circuit emulator by using the serial jtag debug interface. jtag is also used for in- system programming (isp) in as little as 10 sec- onds, perfect for manufacturing and lab develop- ment. the 8032 core is coupled to programmable system device (psd) architecture to optimize the 8032 memory structure, offering two independent banks of flash memory that can be placed at vir- tually any address within 8032 program or data ad- dress space, and easily paged beyond 64k bytes using on-chip programmable decode logic. dual flash memory banks provide a robust solu- tion for remote product updates in the field through in-application programming (iap). dual flash banks also support eeprom emulation, eliminat- ing the need for external eeprom chips. general purpose programmable logic (pld) is in- cluded to build an endless variety of glue-logic, saving external logic devices. the pld is config- ured using the software development tool, psd- soft express, available from the web at www.st.com/psm , at no charge. the upsd34xx also includes supervisor functions such as a programmable watchdog timer and low- voltage reset. note: for a list of known limitations of the upsd34xx devices, please refer to important notes, page 262 .
upsd34xx - summary description 8/264 figure 2. block diagram pa0:7 pb0:7 pd1:2 pc0:7 mcu bus p4.0:7 p1.0:7 p3.0:7 upsd34xx system bus dedicated pins supervisor: watchdog and low-voltage reset 1st flash memory: 64k, 128k, or 256k bytes 2nd flash memory: 32k bytes sram: 4k or 8k bytes programmable decode and page logic general purpose programmable logic, 16 macrocells (8) gpio, port a (80-pin only) (8) gpio, port b (4) gpio, port c (2) gpio, port d jtag ice and isp 8032 address/data/control bus (80-pin device only) v cc , v dd , gnd, reset, crystal in turbo 8032 core pfq & bc (3) 16-bit timer/ counters (2) external interrupts i 2 c spi (8) 10-bit adc uart0 (8) gpio, port 1 (8) gpio, port 3 (8) gpio, port 4 usb+, usb? usb v2.0, full speed 10 fifos uart1 optional irda encoder/decoder 16-bit pca (6) pwm, capcom, timer ai09695
9/264 upsd34xx - pin descriptions pin descriptions figure 3. tqfp52 connections note: 1. for 5v applications, v dd must be connected to a 5.0v source. for 3.3v applications, v dd must be connected to a 3.3v source. 2. these signals can be used on one of two different ports (port 1 or port 4) for flexibility. default is port1. 3. av ref and 3.3v av cc are shared in the 52-pin package only. adc channels must use 3.3v as av ref for the 52-pin package. 39 p1.5/spirxd (2) /adc5 38 p1.4/spiclk (2) /adc4 37 p1.3/txd1(irda) (2) /adc3 36 p1.2/rxd1(irda) (2) /adc2 35 p1.1/t2x (2) /adc1 34 p1.0/t2 (2) /adc0 33 v dd (1) 32 xtal2 31 xtal1 30 p3.7/scl 29 p3.6/sda 28 p3.5/c1 27 p3.4/c0 pd1/clkin pc7 jtag tdo jtag tdi debug 3.3v v cc usb+ v dd (1) gnd usb? pc2/v stby jtag tck jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 52 51 50 49 48 47 46 45 44 43 42 41 40 pb0 pb1 pb2 pb3 pb4 av cc /v ref (3) pb5 gnd reset_in pb6 pb7 p1.7/spisel (2) /adc7 p1.6/spitxd (2) /adc6 14 15 16 17 18 19 20 21 22 23 24 25 26 spisel (2) /pcaclk1/p4.7 spitxd (2) /tcm5/p4.6 spirxd (2) /tcm4/p4.5 spiclk (2) /tcm3/p4.4 txd1(irda) (2) /pcaclk0/p4.3 gnd rxd1(irda) (2) /tcm2/p4.2 t2x (2) /tcm1/p4.1 t2 (2) /tcm0/p4.0 rxd0/p3.0 txd0/p3.1 extint0/tg0/p3.2 extint1/tg1/p3.3 ai09696
upsd34xx - pin descriptions 10/264 figure 4. tqfp80 connections note: nc = not connected note: 1. the usb+ pin needs a 1.5k ? pull-up resistor. 2. for 5v applications, v dd must be connected to a 5.0v source. for 3.3v applications, v dd must be connected to a 3.3v source. 3. these signals can be used on one of two different ports (port 1 or port 4) for flexibility. default is port1. 60 p1.5/spirxd (3) /adc5 59 p1.4/spiclk (3) /adc4 58 p1.3/txd1(irda) (3) /adc3 57 nc 56 p1.2/rxd1(irda) (3) /adc2 55 nc 54 p1.1/t2x (3) /adc1 53 nc 52 p1.0/t2 (3) /adc0 51 nc 50 v dd (1) 49 xtal2 48 xtal1 47 mcu ad7 46 p3.7/scl 45 mcu ad6 44 p3.6/sda 43 mcu ad5 42 p3.5/c1 41 mcu ad4 pd2/csi p3.3/tg1/exint1 pd1/clkin ale pc7 jtag tdo jtag tdi debug pc4/terr 3.3v v cc usb+ (1) v dd (2) gnd usb? pc3/tstat pc2/v stby jtag tck spisel (2) /pcaclk1/p4.7 spitxd (2) /tcm5/p4.6 jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 pb0 p3.2/exint0/tg0 pb1 p3.1/txd0 pb2 p3.0/rxd0 pb3 pb4 av cc pb5 v ref gnd reset_in pb6 pb7 rd p1.7/spisel (3) /adc7 psen wr p1.6/spitxd (3) /adc6 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 pa7 pa6 spirxd (2) /tcm4/p4.5 pa5 spiclk (2) /tcm3/p4.4 pa4 txd1(irda) (2) /pcaclk0/p4.3 pa3 gnd rxd1(irda) (2) /tcm2/p4.2 t2x (2) /tcm1/p4.1 pa2 t2 (2) /tcm0/p4.0 pa1 pa0 mcu ad0 mcu ad1 mcu ad2 mcu ad3 p3.4/c0 ai09697
11/264 upsd34xx - pin descriptions table 2. pin definitions port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2 mcuad0 ad0 36 n/a i/o external bus multiplexed address/ data bus a0/d0 mcuad1 ad1 37 n/a i/o multiplexed address/ data bus a1/d1 mcuad2 ad2 38 n/a i/o multiplexed address/ data bus a2/d2 mcuad3 ad3 39 n/a i/o multiplexed address/ data bus a3/d3 mcuad4 ad4 41 n/a i/o multiplexed address/ data bus a4/d4 mcuad5 ad5 43 n/a i/o multiplexed address/ data bus a5/d5 mcuad6 ad6 45 n/a i/o multiplexed address/ data bus a6/d6 mcuad7 ad7 47 n/a i/o multiplexed address/ data bus a7/d7 p1.0 t2 adc0 52 34 i/o general i/o port pin timer 2 count input (t2) adc channel 0 input (adc0) p1.1 t2x adc1 54 35 i/o general i/o port pin timer 2 trigger input (t2x) adc channel 1 input (adc1) p1.2 rxd1 adc2 56 36 i/o general i/o port pin uart1 or irda receive (rxd1) adc channel 2 input (adc2) p1.3 txd1 adc3 58 37 i/o general i/o port pin uart or irda transmit (txd1) adc channel 3 input (adc3) p1.4 spiclk adc4 59 38 i/o general i/o port pin spi clock out (spiclk) adc channel 4 input (adc4) p1.5 spirxd adc6 60 39 i/o general i/o port pin spi receive (spirxd) adc channel 5 input (adc5) p1.6 spitxd adc6 61 40 i/o general i/o port pin spi transmit (spitxd) adc channel 6 input (adc6) p1.7 spisel adc7 64 41 i/o general i/o port pin spi slave select (spisel) adc channel 7 input (adc7) p3.0 rxd0 75 23 i/o general i/o port pin uart0 receive (rxd0) p3.1 txd0 77 24 i/o general i/o port pin uart0 transmit (txd0) p3.2 exint0 tgo 79 25 i/o general i/o port pin interrupt 0 input (extint0)/timer 0 gate control (tg0) p3.3 int1 2 26 i/o general i/o port pin interrupt 1 input (extint1)/timer 1 gate control (tg1) p3.4 c0 40 27 i/o general i/o port pin counter 0 input (c0) p3.5 c1 42 28 i/o general i/o port pin counter 1 input (c1) p3.6 sda 44 29 i/o general i/o port pin i 2 c bus serial data (i 2 csda) p3.7 scl 46 30 i/o general i/o port pin i 2 c bus clock (i 2 cscl) p4.0 t2 tcm0 33 22 i/o general i/o port pin program counter array0 pca0-tcm0 timer 2 count input (t2)
upsd34xx - pin descriptions 12/264 p4.1 t2x tcm1 31 21 i/o general i/o port pin pca0-tcm1 timer 2 trigger input (t2x) p4.2 rxd1 tcm2 30 20 i/o general i/o port pin pca0-tcm2 uart1 or irda receive (rxd1) p4.3 txd1 pcaclk0 27 18 i/o general i/o port pin pcaclk0 uart1 or irda transmit (txd1) p4.4 spiclk tcm3 25 17 i/o general i/o port pin program counter array1 pca1-tcm3 spi clock out (spiclk) p4.5 spirxd tcm4 23 16 i/o general i/o port pin pca1-tcm4 spi receive (spirxd) p4.6 spitxd 19 15 i/o general i/o port pin pca1-tcm5 spi transmit (spitxd) p4.7 spisel pcaclk1 18 14 i/o general i/o port pin pcaclk1 spi slave select (spisel) v ref 70 n/a i reference voltage input for adc rd 65 n/a o read signal, external bus wr 62 n/a o write signal, external bus psen 63 n/a o psen signal, external bus ale 4 n/a o address latch signal, external bus reset_in 68 44 i active low reset input xtal1 48 31 i oscillator input pin for system clock xtal2 49 32 o oscillator output pin for system clock debug 8 5 i/o i/o to the mcu debug unit pa0 35 n/a i/o general i/o port pin all port a pins support: 1. pld macro-cell outputs, or 2. pld inputs, or 3. latched address out (a0-a7), or 4. peripheral i/o mode pa1 34 n/a i/o general i/o port pin pa2 32 n/a i/o general i/o port pin pa3 28 n/a i/o general i/o port pin pa4 26 n/a i/o general i/o port pin pa5 24 n/a i/o general i/o port pin pa6 22 n/a i/o general i/o port pin pa7 21 n/a i/o general i/o port pin pb0 80 52 i/o general i/o port pin all port b pins support: 1. pld macro-cell outputs, or 2. pld inputs, or 3. latched address out (a0-a7) pb1 78 51 i/o general i/o port pin pb2 76 50 i/o general i/o port pin pb3 74 49 i/o general i/o port pin pb4 73 48 i/o general i/o port pin pb5 71 46 i/o general i/o port pin pb6 67 43 i/o general i/o port pin pb7 66 42 i/o general i/o port pin jtagtms tms 20 13 i jtag pin (tms) jtagtck tck 17 12 i jtag pin (tck) port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2
13/264 upsd34xx - pin descriptions note: 1. n/a = signal not available on 52-pin package. pc2 v stby 16 11 i/o general i/o port pin sram standby voltage input (v stby ) pld macrocell output, or pld input pc3 tstat 15 n/a i/o general i/o port pin optional jtag status (tstat) pld, macrocell output, or pld input pc4 terr 9 n/a i/o general i/o port pin optional jtag status (terr ) pld, macrocell output, or pld input jtagtdi tdi 7 4 i jtag pin (tdi) jtagtdo tdo 6 3 o jtag pin (tdo) pc7 5 2 i/o general i/o port pin pld, macrocell output, or pld input pd1 clkin 3 1 i/o general i/o port pin 1. pld i/o 2. clock input to pld and apd pd2 csi 1 n/a i/o general i/o port pin 1. pld i/o 2. chip select ot psd module usb+ 11 7 i/o usb d+ pin; 1.5k ? pull-up resistor is required. usb? 14 10 i/o usb d? pin 3.3v-v cc 10 6 v cc - mcu module av cc 72 47 analog v cc input v dd 3.3v or 5v 12 8 v dd - psd module v dd - 3.3v for 3v v dd - 5v for 5v v dd 3.3v or 5v 50 33 v dd - psd module v dd - 3.3v for 3v v dd - 5v for 5v gnd 13 9 gnd 29 19 gnd 69 45 nc 11 n/a nc 51 n/a nc 53 n/a nc 55 n/a nc 57 n/a port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2
upsd34xx - hardware description 14/264 hardware description the upsd34xx has a modular architecture built from a stacked die process. there are two die, one is designated ?mcu module? in this document, and the other is designated ?psd module? (see figure 5., page 15 ). in all cases, the mcu module die op- erates at 3.3v with 5v tolerant i/o. the psd mod- ule is either a 3.3v die or a 5v die, depending on the upsd34xx device as described below. the mcu module consists of a fast 8032 core, that operates with 4 clocks per instruction cycle, and has many peripheral and system supervisor func- tions. the psd module provides the 8032 with multiple memories (two flash and one sram) for program and data, programmable logic for ad- dress decoding and for general-purpose logic, and additional i/o. the mcu module communicates with the psd module through internal address and data busses (ad0 ? ad15) and control signals (rd , wr , psen , ale, reset ). there are slightly different i/o characteristics for each module. i/os for the mcu module are desig- nated as ports 1, 3, and 4. i/os for the psd mod- ule are designated as ports a, b, c, and d. for all 5v upsd34xx devices, a 3.3v mcu module is stacked with a 5v psd module. in this case, a 5v upsd34xx device must be supplied with 3.3v cc for the mcu module and 5.0v dd for the psd module. ports 3 and 4 of the mcu module are 3.3v ports with tolerance to 5v devices (they can be directly driven by external 5v devices and they can directly drive external 5v devices while producing a v oh of 2.4v min and v cc max). ports a, b, c, and d of the psd module are true 5v ports. for all 3.3v upsd34xxv devices, a 3.3v mcu module is stacked with a 3.3v psd module. in this case, a 3.3v upsd34xx device needs to be sup- plied with a single 3.3v voltage source at both v cc and v dd . i/o pins on ports 3 and 4 are 5v tolerant and can be connected to external 5v peripherals devices if desired. ports a, b, c, and d of the psd module are 3.3v ports, which are not tolerant to external 5v devices. refer to table 3 for port type and voltage source requirements. 80-pin upsd34xx devices provide access to 8032 address, data, and control signals on external pins to connect external peripheral and memory devic- es. 52-pin upsd34xx devices do not provide ac- cess to the 8032 system bus. all non-volatile memory and configuration portions of the upsd34xx device are programmed through the jtag interface and no special programming voltage is needed. this same jtag port is also used for debugging of the 8032 core at runtime providing breakpoint, single-step, display, and trace features. a non-volatile security bit may be programmed to block all access via jtag inter- face for security. the security bit is defeated only by erasing the entire device, leaving the device blank and ready to use again. table 3. port type and voltage source combinations device type v cc for mcu module v dd for psd module ports 1, 3, and 4 on mcu module ports a, b, c, and d on psd module 5v: upsd34xx 3.3v 5.0v 3.3v (ports 3 and 4 are 5v tolerant) 5v 3.3v: upsd34xxv 3.3v 3.3v 3.3v (ports 3 and 4 are 5v tolerant) 3.3v. not 5v tolerant
15/264 upsd34xx - hardware description figure 5. functional modules 10-bit adc dedicated memory interface prefetch, branch cache enhanced mcu interface decode pld psd page register sram cpld - 16 macrocells jtag isp reset logic wdt internal reset port 1 port 3 dual uarts interrupt 3 timer / counters 256 byte sram turbo 8032 core psd internal bus 8032 internal bus psd reset lvd i 2 c unit usb and trans- ceiver port d gpio port c jtag and gpio secondary flash reset input upsd34xx jtag debug 8-bit/16-bit die-to-die bus main flash pca pwm counters reset pin ext. bus spi v cc pins 3.3v v dd pins 3.3v or 5v mcu module psd module port 3 - uart0, intr, timers port 1 - timer, adc, spi port 4 - pca, pwm, uart1 port 3 i 2 c usb pins xtal clock unit port a,b,c pld i/o and gpio ai10409
upsd34xx - memory organization 16/264 memory organization the 8032 mcu core views memory on the mcu module as ?internal? memory and it views memory on the psd module as ?external? memory, see figure 6. internal memory on the mcu module consists of data, idata, and sfrs. these standard 8032 memories reside in 384 bytes of sram located at a fixed address space starting at address 0x0000. external memory on the psd module consists of four types: main flash (64k, 128k, or 256k bytes), a smaller secondary flash (32k), sram (4k or 8k bytes), and a block of psd module control regis- ters called csiop (256 bytes). these external mem- ories reside at programmable address ranges, specified using the software tool psdsoft express. see the psd module section of this document for more details on these memories. external memory is access ed by the 8032 in two separate 64k byte address spaces. one address space is for program memory and the other ad- dress space is for data memory. program memory is accessed using the 8032 signal, psen . data memory is accessed using the 8032 signals, rd and wr . if the 8032 needs to access more than 64k bytes of external program or data memory, it must use paging (or banking) techniques provided by the page register in the psd module. note: when referencing program and data mem- ory spaces, it has nothing to do with 8032 internal sram areas of data, idata, and sfr on the mcu module. program and data memory spaces only relate to the external memories on the psd module. external memory on the psd module can overlap the internal sram memory on the mcu module in the same physical address range (starting at 0x0000) without interference because the 8032 core does not assert the rd or wr signals when accessing internal sram. figure 6. upsd34xx memories  external memories may be placed at virtually any address using software tool psdsoft express.  the sram and flash memories may be placed in 8032 program space or data space using psdsoft express.  any memory in 8032 data space is xdata. 64kb or 128kb or 256kb 32kb main flash internal sram on mcu module external memory on psd module i data sfr data secondary flash 4kb or 8kb sram 384 bytes sram direct or indirect addressing ff 80 7f 128 bytes 128 bytes 128 bytes 0 indirect addressing fixed addresses direct addressing ai10410
17/264 upsd34xx - memory organization internal memory (mcu module, standard 8032 memory: data, idata, sfr) data memory. the first 128 bytes of internal sram ranging from address 0x0000 to 0x007f are called data, which can be accessed using 8032 direct or indirect addressing schemes and are typically used to store variables and stack. four register banks, each with 8 registers (r0 ? r7), occupy addresses 0x0000 to 0x001f. only one of these four banks may be enabled at a time. the next 16 locations at 0x0020 to 0x002f contain 128 directly addressable bit locations that can be used as software flags. sram locations 0x0030 and above may be used for variables and stack. idata memory. the next 128 bytes of internal sram are named idata and range from address 0x0080 to 0x00ff. idata can be accessed only through 8032 indirect addressing and is typically used to hold the mcu stack as well as data vari- ables. the stack can reside in both data and idata memories and reach a size limited only by the available space in the combined 256 bytes of these two memories (since stack accesses are al- ways done using indirect addressing, the bound- ary between data and idata does not exist with regard to the stack). sfr memory. special function registers ( table 5., page 25 ) occupy a separate physical memory, but they logically overlap the same 128 bytes as idata, ranging from address 0x0080 to 0x00ff. sfrs are accessed only using direct addressing . there 86 active registers used for many functions: changing the operating mode of the 8032 mcu core, controlling 8032 peri pherals, controlling i/o, and managing interrupt functions. the remaining unused sfrs are reserved and should not be ac- cessed. 16 of the sfrs are both byte- and bit-addressable. bit-addressable sfrs are those whose address ends in ?0? or ?8? hex. external memory (psd module: program memory, data memory) the psd module has four memories: main flash, secondary flash, sram, and csiop. see the psd module section for more detailed information on these memories. memory mapping in the psd module is imple- mented with the decode pld (dpld) and option- ally the page register. the user specifies decode equations for individual segments of each of the memories using the software tool psdsoft ex- press. this is a very easy point-and-click process allowing total flex ibility in mapping memories. ad- ditionally, each of the memories may be placed in various combinations of 8032 program address space or 8032 data address space by using the software tool psdsoft express. program memory. external program memory is addressed by the 8032 using its 16-bit program counter (pc) and is accessed with the 8032 sig- nal, psen . program memory can be present at any address in program space between 0x0000 and 0xffff. after a power-up or reset, the 8032 begins pro- gram execution from location 0x0000 where the reset vector is stored, caus ing a jump to an initial- ization routine in firmware. at address 0x0003, just following the re set vector are the interrupt service locations. each interrupt is assigned a fixed inter- rupt service location in program memory. an inter- rupt causes the 8032 to jump to that service location, where it commences execution of the service routine. external interrupt 0 (exint0), for example, is assigned to service location 0x0003. if exint0 is going to be used, its service routine must begin at location 0x0003. interrupt service lo- cations are spaced at 8-byte intervals: 0x0003 for exint0, 0x000b for timer 0, 0x0013 for exint1, and so forth. if an interrupt service routine is short enough, it can reside entirely within the 8-byte in- terval. longer service routines can use a jump in- struction to somewhere else in program memory. data memory. external data is referred to as xdata and is addressed by the 8032 using indi- rect addressing via its 16-bit data pointer register (dptr) and is accessed by the 8032 signals, rd and wr . xdata can be present at any address in data space between 0x0000 and 0xffff. note: the upsd34xx has dual data pointers (source and destination) making xdata transfers much more efficient. memory placement. psd module architecture allows the placement of its external memories into different combinations of program memory and data memory spaces. this means the main flash, the secondary flash, and the sram can be viewed by the 8032 mcu in various combinations of program memory or data memory as defined by psdsoft express. as an example of this fl exibility, for applications that require a great deal of flash memory in data space (large lookup tables or extended data re- cording), the larger main flash memory can be placed in data space and the smaller secondary flash memory can be placed in program space. the opposite can be realized for a different appli- cation if more flash memory is needed for code and less flash memory for data.
upsd34xx - 8032 mcu core performance enhancements 18/264 by default, the sram and csiop memories on the psd module must always reside in data memory space and they are treated by the 8032 as xda- ta. the main flash and secondary flash memories may reside in program space, data space, or both. these memory placement choices specified by psdsoft express are programmed into non-vola- tile sections of the upsd34xx, and are active at power-up and after reset. it is possible to override these initial settings during runtime for in-applica- tion programming (iap). standard 8032 mcu architecture cannot write to its own program memory space to prevent acci- dental corruption of firmware. however, this be- comes an obstacle in typical 8032 systems when a remote update to firmware in flash memory is required using iap. the psd module provides a solution for remote updates by allowing 8032 firm- ware to temporarily ?reclassify? flash memory to reside in data space during a remote update, then returning flash memory back to program space when finished. see the vm register ( table 104., page 174 ) in the psd module section of this document for more details. 8032 mcu core performance enhancements before describing performance features of the upsd34xx, let us first look at standard 8032 archi- tecture. the clock source for the 8032 mcu cre- ates a basic unit of timing called a machine-cycle, which is a period of 12 clocks for standard 8032 mcus. the instruction set for traditional 8032 mcus consists of 1, 2, and 3 byte instructions that execute in different combinations of 1, 2, or 4 ma- chine-cycles. for example, there are one-byte in- structions that execute in one machine-cycle (12 clocks), one-byte instructions that execute in four machine-cycles (48 clocks), two-byte, two-cycle instructions (24 clocks), and so on. in addition, standard 8032 architectu re will fetch two bytes from program memory on almost every machine- cycle, regardless if it needs them or not (dummy fetch). this means for on e-byte, one-cycle instruc- tions, the second byte is ignored. these one-byte, one-cycle instructions ac count for half of the 8032's instructions (126 out of 255 opcodes). there are inefficiencies due to wasted bus cycles and idle bus times that can be eliminated. the upsd34xx 8032 mcu core offers increased performance in a number of ways, while keeping the exact same instruction set as the standard 8032 (all opcodes, the number of bytes per in- struction, and the native number a machine-cycles per instruction are identical to the original 8032). the first way performance is boosted is by reduc- ing the machine-cycle period to just 4 mcu clocks as compared to 12 mcu clocks in a standard 8032. this shortened machine-cycle improves the instruction rate for one- or two-byte, one-cycle in- structions by a factor of three ( figure 7., page 19 ) compared to standard 8051 architectures, and sig- nificantly improves perf ormance of multiple-cycle instruction types. the example in figure 7 shows a continuous exe- cution stream of one- or two-byte, one-cycle in- structions. the 5v upsd34xx will yield 10 mips peak performance in this case while operating at 40mhz clock rate. in a typical application however, the effective per formance will be lower since pro- grams do not use only one-cycle instructions, but special techniques are implemented in the upsd34xx to keep the effective mips rate as close as possible to the peak mips rate at all times. this is accomp lished with an instruction pre-fetch queue (pfq), a branch cache (bc), and a 16-bit program memory bus as shown in figure 8., page 19 .
19/264 upsd34xx - 8032 mcu core performance enhancements figure 7. comparison of upsd34xx with standard 8032 performance figure 8. instruction pre-fetch queue and branch cache mcu clock standard 8032 fetch byte for instruction a execute instruction a and fetch a second dummy byte turbo upsd34xx execute instruction and pre-fetch next instruction 4 clocks (one machine cycle) 12 clocks (one machine cycle) 1- or 2-byte, 1-cycle instructions dummy byte is ignored (wasted bus access) execute instruction and pre-fetch next instruction execute instruction and pre-fetch next instruction instruction a instruction b instruction c instruction a turbo upsd34xx executes instructions a, b, and c in the same amount of time that a standard 8032 executes only instruction a. one machine cycle one machine cycle ai10411 branch 4 code branch 4 code 8032 mcu 16-bit program memory on psd module instruction pre-fetch queue (pfq) 4 bytes of instruction instruction byte wait wait 8 instruction byte 8 instruction byte 8 current branch address compare branch cache (bc) 16 ai10431 address 16 16 16 address load on branch address match branch 3 code branch 3 code branch 2 code branch 2 code branch 1 code branch 1 code
upsd34xx - 8032 mcu core performance enhancements 20/264 pre-fetch queue (pfq) and branch cache (bc) the pfq is always working to minimize the idle bus time inherent to 8032 mcu architecture, to eliminate wasted memory fetches, and to maxi- mize memory bandwidth to the mcu. the pfq does this by running asynchronously in relation to the mcu, looking ahead to pre-fetch two bytes (word) of code from program memory during any idle bus periods. only necessary word will be fetched (no dummy fetches like standard 8032). the pfq will queue up to four code bytes in ad- vance of execution, whic h significantly optimizes sequential program performance. however, when program execution becomes non-sequential (pro- gram branch), a typica l pre-fetch queue will empty itself and reload new code, causing the mcu to stall. the turbo upsd34xx diminishes this prob- lem by using a branch cache with the pfq. the bc is a four-way, fully associative cache, meaning that when a program branch occurs, its branch destination address is compared simultaneously with four recent previous branch destinations stored in the bc. each of the four cache entries contain up to four bytes of code related to a branch. if there is a hit (a match), then all four code bytes of the matching program branch are trans- ferred immediately and simultaneously from the bc to the pfq, and execution on that branch con- tinues with minimal delay. this greatly reduces the chance that the mcu will st all from an empty pfq, and improves performance in embedded control systems where it is quite common to branch and loop in relatively small code localities. by default, the pfq and bc are enabled after power-up or reset. the 8032 can disable the pfq and bc at runtime if desired by writing to a specific sfr (buscon). the memory in the psd module operates with variable wait states depending on the value spec- ified in the sfr named buscon. for example, a 5v upsd34xx device operating at a 40mhz crystal frequency requires four memory wait states (equal to four mcu clocks). in this example, once the pfq has one word of code, the wait states be- come transparent and a full 10 mips is achieved when the program stream consists of sequential one- or two-byte, one machine-cycle instructions as shown in figure 7., page 19 (transparent be- cause a machine-cycle is four mcu clocks which equals the memory pre-fetch wait time that is also four mcu clocks). but it is also important to under- stand pfq operation on multi-cycle instructions. pfq example, multi-cycle instructions let us look at a string of two-byte, two-cycle in- structions in figure 9., page 21 . there are three instructions executed sequentially in this example, instructions a, b, and c. each of the time divisions in the figure is one machine-cycle of four clocks, and there are six phases to reference in this dis- cussion. each instruction is pre-fetched into the pfq in advance of execution by the mcu. prior to phase 1, the pfq has pre-fetched the two instruc- tion bytes (a1 and a2) of instruction a. during phase one, both bytes are loaded into the mcu execution unit. also in phase 1, the pfq is pre- fetching instruction b (bytes b1 and b2) from pro- gram memory. in phase 2, the mcu is processing instruction a internally while the pfq is pre-fetch- ing instruction c. in phase 3, both bytes of instruc- tion b are loaded into the mcu execution unit and the pfq begins to pre-fetch bytes for the next in- struction. in phase 4 instruction b is processed. the upsd34xx mcu instructions are an exact 1/3 scale of all standard 8032 instructions with regard to number of cycles per instruction. figure 10., page 21 shows the equivalent instruction se- quence from the example above on a standard 8032 for comparison. aggregate performance the stream of two-byte, two-cycle instructions in figure 9., page 21 , running on a 40mhz, 5v, upsd34xx will yield 5 mips. and we saw the stream of one- or two-byte, one-cycle instructions in figure 7., page 19 , on the same mcu yield 10 mips. effective performance will depend on a number of things: the mcu clock frequency; the mixture of instructions types (bytes and cycles) in the application; the amount of time an empty pfq stalls the mcu (mix of in struction types and miss- es on branch cache); and the operating voltage. a 5v upsd34xx device operates with four memory wait states, but a 3.3v device operates with five memory wait states yielding 8 mips peak com- pared to 10 mips peak for 5v device. the same number of wait states will apply to both program fetches and to data read/writes unless other- wise specified in the sfr named buscon. in general, a 3x aggregate performance increase is expected over any standard 8032 application running at the same clock frequency.
21/264 upsd34xx - 8032 mcu core performance enhancements figure 9. pfq operation on multi-cycle instructions figure 10. upsd34xx multi-cycle instructions compared to standard 8032 three 2-byte, 2-cycle instructions on upsd34xx pfq mcu execution inst a, byte 1&2 inst b, byte 1&2 inst c, byte 1&2 next inst previous instruction a1 a2 process a b1 b2 process b c1 c2 ai10432 process c continue to pre-fetch next inst 4-clock macine cycle instruction a instruction b instruction c pre-fetch inst a pre-fetch inst b and c pre-fetch next inst phase 1 phase 2 phase 3 phase 4 phase 6 phase 5 a1 a2 inst a b1 b2 inst b c1 c2 inst c three 2-byte, 2-cycle instructions, upsd34xx vs. standard 8032 upsd34xx std 8032 72 clocks (12 clocks per cycle) 24 clocks total (4 clocks per cycle) byte 1 byte 2 process inst a byte 1 byte 2 process inst b byte 1 byte 2 process inst c ai10412 1 cycle 1 cycle
upsd34xx - mcu module discription 22/264 mcu module discription this section provides a detail description of the mcu module system functions and peripherals, in- cluding: 8032 mcu registers special function registers 8032 addressing modes upsd34xx instruction set summary dual data pointers debug unit interrupt system mcu clock generation power saving modes oscillator and external components i/o ports mcu bus interface supervisory functions standard 8032 timer/counters serial uart interfaces irda interface i 2 c interface spi interface analog to digital converter programmable counter array (pca) usb interface note: a full description of the 8032 instruction set may be found in the upsd34xx programmers guide. 8032 mcu registers the upsd34xx has the following 8032 mcu core registers, also shown in figure 11 . figure 11. 8032 mcu registers stack pointer (sp) the sp is an 8-bit register which holds the current location of the top of the stack. it is incremented before a value is pushed onto the stack, and dec- remented after a value is popped off the stack. the sp is initialized to 07h af ter reset. this causes the stack to begin at location 08h (top of stack). to avoid overlapping conflicts, the user must initialize the top of the stack to 20h if all four banks of reg- isters r0 - r7 are used, as well as the top of stack to 30h if all of the 8032 bit memory locations are used. data pointer (dptr) dptr is a 16-bit register consisting of two 8-bit registers, dpl and dph. the dptr register is used as a base register to create an address for in- direct jumps, table look-up operations, and for ex- ternal data transfers (xdata). when not used for addressing, the dptr register can be used as a general purpose 16-bit data register. very frequently, the dptr register is used to ac- cess xdata using the ex ternal direct addressing mode. the upsd34xx has a special set of sfr registers (dptc, dptm) to control a secondary dptr register to speed memory-to-memory xdata transfers. having dual dptr registers al- lows rapid switching between source and destina- tion addresses (see details in dual data pointers, page 38 ). program counter (pc) the pc is a 16-bit register consisting of two 8-bit registers, pcl and pch. this counter indicates the address of the next instruction in program memory to be fetched and executed. a reset forc- es the pc to location 0000h, which is where the re- set jump vector is stored. accumulator (acc) this is an 8-bit general purpose register which holds a source operand and receives the result of arithmetic operations. the acc register can also be the source or destination of logic and data movement operations. for mul and div instruc- tions, acc is combined with the b register to hold 16-bit operands. the acc is referred to as ?a? in the mcu instruction set. b register (b) the b register is a general purpose 8-bit register for temporary data storage and also used as a 16- bit register when concatenated with the acc reg- ister for use with mul and div instructions. ai06636 accumulator b register stack pointer program counter program status word general purpose register (bank0-3) data pointer register pch dptr(dph) a b sp pcl psw r0-r7 dptr(dpl)
23/264 upsd34xx - 8032 mcu registers general purpose registers (r0 - r7) there are four banks of eight general purpose 8- bit registers (r0 - r7), but only one bank of eight registers is active at any given time depending on the setting in the psw word (described next). r0 - r7 are generally used to assist in manipulating values and moving data from one memory location to another. these register banks physically reside in the first 32 locations of 8032 internal data sram, starting at address 00h. at reset, only the first bank of eight registers is active (addresses 00h to 07h), and the stack begins at address 08h. program status word (psw) the psw is an 8-bit register which stores several important bits, or flags, that are set and cleared by many 8032 instructions, reflecting the current state of the mcu core. figure 12., page 23 shows the individual flags. carry flag (cy). this flag is set when the last arithmetic operation that was executed results in a carry (addition) or borrow (subtraction). it is cleared by all other arithmetic operations. the cy flag is also affected by shift and rotate instruc- tions. auxiliary carry flag (ac). this flag is set when the last arithmetic operation that was executed re- sults in a carry into (addition) or borrow from (sub- traction) the high-order nibble. it is cleared by all other arithmetic operations. general purpose flag (f0). this is a bit-addres- sable, general-purpose flag for use under software control. register bank select flags (rs1, rs0). these bits select which bank of eight registers is used during r0 - r7 register accesses (see table 4 ) overflow flag (ov). the ov flag is set when: an add, addc, or subb instruction causes a sign change; a mul instruction results in an overflow (result greater than 255); a div instruction causes a divide-by-zero condition. the ov flag is cleared by the add, addc, subb, mul, and div instruc- tions in all other cases. the clrv instruction will clear the ov flag at any time. parity flag (p). the p flag is set if the sum of the eight bits in the accumulator is odd, and p is cleared if the sum is even. table 4. .register bank select addresses figure 12. program status word (psw) register rs1 rs0 register bank 8032 internal data address 0 0 0 00h - 07h 0 1 1 08h - 0fh 1 0 2 10h - 17h 1 1 3 18h - 1fh ai06639 cy reset value 00h parity flag bit not assigned overflow flag register bank select flags (to select bank0-3) carry flag auxillary carry flag general purpose flag ac fo rs1 rs0 ov p msb lsb psw
upsd34xx - special function registers (sfr) 24/264 special function registers (sfr) a group of registers designated as special func- tion register (sfr) is shown in table 5., page 25 . sfrs control the operating modes of the mcu core and also control the peripheral interfaces and i/o pins on the mcu module. the sfrs can be ac- cessed only by using the direct addressing meth- od within the address range from 80h to ffh of internal 8032 sram. sixteen addresses in sfr address space are both byte- and bit-addressable. the bit-addressable sfrs are noted in table 5 . 106 of a possible 128 sfr addresses are occu- pied. the remaining unoccupied sfr addresses (designated as ?r eserved? in table 5 ) should not be written. reading unoccupied locations will return an undefined value. note: there is a separate set of control registers for the psd module, designated as csiop, and they are described in the psd module, page 164 . the i/o pins, pld, and other functions on the psd module are not controlled by sfrs. sfrs are categorized as follows: mcu core registers: ip, a, b, psw, sp, dptl, dpth, dptc, dptm mcu module i/o port registers: p1, p3, p4, p1sfs0, p1sfs1, p3sfs, p4sfs0, p4sfs1 standard 8032 timer registers tcon, tmod, t2con, th0, th1, th2, tl0, tl1, tl2, rcap2l, rcap2h standard serial interfaces (uart) scon0, sbuf0, scon1, sbuf1 power, clock, and bus timing registers pcon, ccon0, ccon1, buscon hardware watchdog timer registers wdkey, wdrst interrupt system registers ip, ipa, ie, iea prog. counter arr ay (pca) control registers pcacl0, pcach0, pcacon0, pcasta, pcacl1, pcach1, pcacon1, ccon2, ccon3 pca capture/compare and pwm registers capcoml0, capcomh0, tcmmode0, capcoml1, capcomh1, tcmmode2, capcoml2, capcomh2, tcmmode2, capcoml3, capcomh3, tcmmode3, capcoml4, capcomh4, tcmmode4, capcoml5, capcomh5, tcmmode5, pwmf0, pmwf1 spi interface registers spiclkd, spistat, spitdr, spirdr, spicon0, spicon1 i 2 c interface registers s1setup, s1con, s1st a, s1dat, s1adr analog to digital converter registers acon, adcps, adat0, adat1 irda interface register irdacon usb interface registers uaddr, upair, we0- 3, uif0-3, uctl, usta, usel, ucon, usize, ubaseh, ubasel, usci, uscv
25/264 upsd34xx - special funct ion registers (sfr) table 5. sfr memory map with direct address and reset value sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210 80 reserved 81 sp sp[7:0] 07 stack pointer (sp), page 22 82 dpl dpl[7:0] 00 data pointer (dptr), p age 22 83 dph dph[7:0] 00 84 reserved 85 dptc ? at ? ? ? dpsel[2:0] 00 table 13., page 38 86 dptm ? ? ? ? md1[1:0] md0[1:0] 00 table 14., page 39 87 pcon smod0 smod1 ? por rclk1 tclk1 pd idle 00 table 26., page 52 88 (1) tcon tf1 <8fh> tr1 <8eh> tf0 <8dh> tr0 <8ch> ie1 <8bh> it1 <8ah> ie0 <89h> it0 <88h> 00 table 41., page 72 89 tmod gate c/t m1 m0 gate c/t m1 m0 00 table 42., page 74 8a tl0 tl0[7:0] 00 standard timer sfrs, pag e71 8b tl1 tl1[7:0] 00 8c th0 th0[7:0] 00 8d th1 th1[7:0] 00 8e p1sfs0 p1sfs0[7:0] 00 table 31., page 61 8f p1sfs1 p1sfs1[7:0] 00 table 32., page 61 90 (1) p1 p1.7 <97h> p1.6 <96h> p1.5 <95h> p1.4 <94h> p1.3 <93h> p1.2 <92h> p1.1 <91h> p1.0 <90h> ff table 27., page 58 91 p3sfs p3sfs[7:0] 00 table 30., page 61 92 p4sfs0 p4sfs0[7:0] 00 table 34., page 62 93 p4sfs1 p4sfs1[7:0] 00 table 35., page 62
upsd34xx - special function registers (sfr) 26/264 94 adcps ? ? ? ? adcce adcps[2:0] 00 table 90., page 153 95 adat0 adata[7:0] 00 table 91., page 153 96 adat1 ? ? ? ? ? ? adata[9:8] 00 table 92., page 153 97 acon aintf ainten aden ads[2:0] adst adsf 00 table 89., page 152 98 (1) scon0 sm0 <9fh> sm1 <9eh> sm2 <9dh> ren <9ch> tb8 <9bh> rb8 <9ah> ti <99h> ri <9h8> 00 table 47., page 84 99 sbuf0 sbuf0[7:0] 00 figure 28., page 81 9a reserved 9b reserved 9c reserved 9d buscon epfq ebc wrw1 wrw0 rdw1 rdw0 cw1 cw0 eb table 37., page 65 9e reserved 9f reserved a0 reserved a1 reserved a2 pcacl0 pcacl0[7:0] 00 table 93., page 155 a3 pcach0 pcach0[7:0] 00 table 93., page 155 a4 pcacon0 en_all en_pca eovf1 pca_idl ? ? clk_sel[1:0] 00 table 96., page 160 a5 pcasta ovf1 intf5 intf4 intf3 ovf0 intf2 intf1 intf0 00 table 98., page 162 a6 wdrst wdrst[7:0] 00 table 40., page 70 a7 iea eadc espi epca es1 ? ? ei2c ? 00 table 18., page 45 sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
27/264 upsd34xx - special funct ion registers (sfr) a8 (1) ie ea ? et2 es0 et1 ex1 et0 ex0 00 table 17., page 45 a9 tcmmode 0 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 table 99., page 163 aa tcmmode 1 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ab tcmmode 2 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ac capcoml 0 capcoml0[7:0] 00 table 93., page 155 ad capcomh 0 capcomh0[7:0] 00 ae wdkey wdkey[7:0] 55 table 39., page 70 af capcoml 1 capcoml1[7:0] 00 table 93., page 155 b0 (1) p3 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 ff table 28., page 59 b1 capcomh 1 capcomh1[7:0] 00 table 93., page 155 b2 capcoml 2 capcoml2[7:0] 00 b3 capcomh 2 capcomh2[7:0] 00 b4 pwmf0 pwmf0[7:0] 00 b5 reserved b6 reserved b7 ipa padc pspi ppca ps1 ? ? pi2c ? 00 table 20., page 46 b8 (1) ip ? ? pt2 ps0 pt1 px1 pt0 px0 00 table 19., page 46 b9 reserved ba pcacl1 pcacl1[7:0] 00 table 93., page 155 bb pcach1 pcach1[7:0] 00 bc pcacon1 ? en_pca eovf1 pca_idl ? ? clk_sel[1:0] 00 table 97., page 161 sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
upsd34xx - special function registers (sfr) 28/264 bd tcmmode 3 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 table 99., page 163 be tcmmode 4 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 bf tcmmode 5 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 c0 (1) p4 p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 ff table 29., page 59 c1 capcoml 3 capcoml3[7:0] 00 table 93., page 155 c2 capcomh 3 capcomh3[7:0] 00 c3 capcoml 4 capcoml4[7:0] 00 c4 capcomh 4 capcomh4[7:0] 00 c5 capcoml 5 capcoml5[7:0] 00 c6 capcomh 5 capcomh5[7:0] 00 c7 pwmf1 pwmf1[7:0] 00 c8 (1) t2con tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/ rl2 00 table 43., page 77 c9 reserved ca rcap2l rcap2l[7:0] 00 standard timer sfrs, pag e71 cb rcap2h rcap2h[7:0] 00 cc tl2 tl2[7:0] 00 cd th2 th2[7:0] 00 ce irdacon ? irda_en bit_puls cdiv4 cdiv3 cdiv2 cdiv1 cdiv0 0f table 50., page 95 d0 (1) psw cy ac f0 rs[1:0] ov ? p 00 program status word (psw), pa ge 23 d1 reserved d2 spiclkd spiclkd[5:0] ? ? 04 table 65., page 121 d3 spistat ? ? ? busy teisf rorisf tisf risf 02 table 66., page 122 sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
29/264 upsd34xx - special funct ion registers (sfr) d4 spitdr spitdr[7:0] 00 table 64., page 121 d5 spirdr spirdr[7:0] 00 d6 spicon0 ? te re spien ssel flsb spo ? 00 table 63., page 120 d7 spicon1 ? ? ? ? teie rorie tie rie 00 table 64., page 121 d8 (1) scon1 sm0 sm2
ren tb8 rb8 ti ri 00 table 48., page 85 d9 sbuf1 sbuf1[7:0] 00 figure 28., page 81 da reserved db s1setup ss_en smpl_set[6:0] 00 table 59., page 108 dc s1con cr2 en1 sta sto addr aa cr1 cr0 00 table 54., page 103 dd s1sta gc stop intr tx_md b_busy b_lost ack_r slv 00 table 56., page 106 de s1dat s1dat[7:0] 00 table 57., page 107 df s1adr s1adr[7:0] 00 table 58., page 107 e0 (1) a a[7:0] 00 accumulat or (acc), pa ge 22 e1 reserved e2 uaddr ? usbaddr[6:0] 00 e3 upair ? ? ? ? pr3out pr1out pr3in pr1in 00 e4 uie0 ? ? ? ? rstie suspnd ie eopie res umie 00 e5 uie1 ? ? ? in4ie in3ie in2ie in1ie in0ie 00 e6 uie2 ? ? ? out4ie out3ie out2ie out1ie out0i e 00 e7 uie3 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0i e 00 e8 uif0 glf inf outf nakf rstf suspnd f eopf resu mf 00 sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
upsd34xx - special function registers (sfr) 30/264 note: 1. this sfr can be addressed by individual bits (bit address mode) or addressed by the entire byte (direct address mode). e9 uif1 ? ? ? in4f in3f in2f in1f in0f 00 ea uif2 ? ? ? out4f out3f out2f out1f out0f 00 eb uif3 ? ? ? nak4f nak3f nak2f nak1f nak0f 00 ec uctl ? ? ? ? ? usben visible wake up 00 ed usta ? ? ? ? rcvt setup in out 00 ee reserved ef usel dir ? ? ? ? ep[2:0] 00 f0 (1) b b[7:0] 00 b register (b), page 22 f1 ucon ? ? ? ? enable stall toggle bsy 00 f2 usize ? size[6:0] 00 f3 ubaseh baseaddr[15:8] 00 f4 ubasel baseaddr[7:6] 0 0 0 0 0 0 00 f5 usci ? ? ? ? ? usci[2:0] 00 f6 uscv uscv[7:0] 00 f7 reserved f8 reserved f9 ccon0 pllm[4] pllen upllce dbgce cpu_ ar cpups[2:0] 50 table 22., page 49 fa ccon1 pllm[3:0] plld[3:0] 00 fb ccon2 ? ? ? pca0ce pca0ps[3:0] 10 table 94., page 156 fc ccon3 ? ? ? pca1ce pca1ps[3:0] 10 table 95., page 156 fd reserved fe reserved ff reserved fe reserved ff reserved sfr addr (hex) sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
31/264 upsd34xx - 8032 addressing modes 8032 addressing modes the 8032 mcu uses 11 different addressing modes listed below: register direct register indirect immediate external direct external indirect indexed relative absolute long bit register addressing this mode uses the contents of one of the regis- ters r0 - r7 (selected by the last three bits in the instruction opcode) as the operand source or des- tination. this mode is very efficient since an addi- tional instruction byte is not needed to identify the operand. for example: direct addressing this mode uses an 8-bit address, which is con- tained in the second byte of the instruction, to di- rectly address an operand which resides in either 8032 data sram (internal address range 00h- 07fh) or resides in 8032 sfr (internal address range 80h-ffh). this mode is quite fast since the range limit is 256 bytes of internal 8032 sram. for example: register indirect addressing this mode uses an 8-bit address contained in ei- ther register r0 or r1 to indirectly address an op- erand which resides in 8032 idata sram (internal address range 80h-ffh). although 8032 sfr registers also occupy the same physical ad- dress range as idata, sfrs will not be accessed by register indirect mode. sfrs may only be ac- cesses using direct address mode. for example: immediate addressing this mode uses 8-bits of data (a constant) con- tained in the second byte of the instruction, and stores it into the memory location or register indi- cated by the first byte of the instruction. thus, the data is immediately available within the instruction. this mode is commonly used to initialize registers and sfrs or to perform mask operations. there is also a 16-bit version of this mode for load- ing the dptr register. in this case, the two bytes following the instruction byte contain the 16-bit val- ue. for example: external direct addressing this mode will access ex ternal memory (xdata) by using the 16-bit address stored in the dptr register. there are only two instructions using this mode and both use the accumulator to either re- ceive a byte from external memory addressed by dptr or to send a byte from the accumulator to the address in dptr. the upsd34xx has a spe- cial feature to alternate the contents (source and destination) of dptr rapidly to implement very ef- ficient memory-to-memory transfers. for example: note: see details in dual data pointers, page 38 . external indirect addressing this mode will access ex ternal memory (xdata) by using the 8-bit address stored in either register r0 or r1. this is the fa stest way to access xdata (least bus cycles), but because only 8-bits are available for address, this mode limits xdata to a size of only 256 bytes (the traditional port 2 of the 8032 mcu is not available in the upsd34xx, so it is not possible to write the upper address byte). this mode is not supported by upsd34xx. for example: mov a, r7 ; move contents of r7 to accumulator mov a, 40h ; move contents of data sram ; at location 40h into the accumulator mov a, @r0 ; move into the accumulator the ; contents of idata sram that is ; pointed to by the address ; contained in r0. mov a, 40# ; move the constant, 40h, into ; the accumulator mov dptr, 1234# ; move the constant, 1234h, into ; dptr movx a, @dptr ; move contents of accumulator to ; xdata at address contained in ; dptr movx @dptr, a ; move xdata to accumulator movx @r0,a ; move into the accumulator the ; xdata that is pointed to by ; the address contained in r0.
upsd34xx - 8032 addressing modes 32/264 indexed addressing this mode is used for th e movc instruction which allows the 8032 to read a constant from program memory (not data memory). movc is often used to read look-up tables that are embedded in pro- gram memory. the final address produced by this mode is the result of adding either the 16-bit pc or dptr value to the contents of the accumulator. the value in the accumulator is referred to as an index. the data fetched from the final location in program memory is stored into the accumulator, overwriting the index value that was previously stored there. for example: relative addressing this mode will add the two?s-complim ent number stored in the second byte of the instruction to the program counter for short jumps within +128 or ? 127 addresses relative to the program counter. this is commonly used for looping and is very effi- cient since no additional bus cycle is needed to fetch the jump destination address. for example: absolute addressing this mode will append the 5 high-order bits of the address of the next instruction to the 11 low-order bits of an acall or ajump instruction to produce a 16-bit jump address. the jump will be within the same 2k byte page of program memory as the first byte of the following instruction. for example: long addressing this mode will use the 16-b its contained in the two bytes following the instruction byte as a jump des- tination address for lcall and ljmp instructions. for example: bit addressing this mode allows setting or clearing an individual bit without disturbing the other bits within an 8-bit value of internal sram. bit addressing is only available for certain locations in 8032 data and sfr memory. valid locations are data address- es 20h - 2fh and for sfr addresses whose base address ends with 0h or 8h. (example: the sfr, ie, has a base address of a8h, so each of the eight bits in ie can be addressed individually at address a8h, a9h, ...up to afh.) for example: movc a, @a+dptr; move code byte relative to ; dptr into accumulator movc a, @a+pc ; move code byte relative to pc ; into accumulator sjmp 34h ; jump 34h bytes ahead (in program ; memory) of the address at which ; the sjmp instruction is stored. if ; sjmp is at 1000h, program ; execution jumps to 1034h. ajmp 0500h ; if next instruction is located at ; address 4000h, the resulting jump ; will be made to 4500h. ljmp 0500h ; unconditionally jump to address ; 0500h in program memory setb afh ; set the individual ea bit (enable all ; interrupts) inside the sfr register, ; ie.
33/264 upsd34xx - upsd34xx instruction set summary upsd34xx instruction set summary tables 6 through 11 list all of the instructions sup- ported by the upsd34xx, including the number of bytes and number of machine cycles required to implement each instruction. this is the standard 8051 instruction set. the meaning of ?machine cycles? is how many 8032 mcu core machine cycles are required to execute the instruction. the ?native? duration of all machine cycles is set by the memory wait state settings in the sfr, buscon, and the mcu clock divider selections in the sfr, ccon0 (i.e. a ma- chine cycle is typically set to 4 mcu clocks for a 5v upsd34xx). however, an individual machine cycle may grow in duration when either of two things happen: 1. a stall is imposed while loading the 8032 pre- fetch queue (pfq); or 2. the occurrence of a cache miss in the branch cache (bc) during a branch in program execution flow. see 8032 mcu core performance enhancements, page 18 or more details. but generally speaking, during typical program ex- ecution, the pfq is not empty and the bc has no misses, producing very good performance without extending the duration of any machine cycles. the upsd34xx programmers guide describes each instruction operation in detail. table 6. arithmetic instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. mnemonic (1) and use description length/cycles add a, rn add register to acc 1 byte/1 cycle add a, direct add direct byte to acc 2 byte/1 cycle add a, @ri add indirect sram to acc 1 byte/1 cycle add a, #data add immediate data to acc 2 byte/1 cycle addc a, rn add register to acc with carry 1 byte/1 cycle addc a, direct add direct byte to acc with carry 2 byte/1 cycle addc a, @ri add indirect sram to acc with carry 1 byte/1 cycle addc a, #data add immediate data to acc with carry 2 byte/1 cycle subb a, rn subtract register from acc with borrow 1 byte/1 cycle subb a, direct subtract direct byte from acc with borrow 2 byte/1 cycle subb a, @ri subtract indirect sram from acc with borrow 1 byte/1 cycle subb a, #data subtract immediate data from acc with borrow 2 byte/1 cycle inc a increment a 1 byte/1 cycle inc rn increment register 1 byte/1 cycle inc direct increment direct byte 2 byte/1 cycle inc @ri increment indirect sram 1 byte/1 cycle dec a decrement acc 1 byte/1 cycle dec rn decrement register 1 byte/1 cycle dec direct decrement direct byte 2 byte/1 cycle dec @ri decrement indirect sram 1 byte/1 cycle inc dptr increment data pointer 1 byte/2 cycle mul ab multiply acc and b 1 byte/4 cycle div ab divide acc by b 1 byte/4 cycle da a decimal adjust acc 1 byte/1 cycle
upsd34xx - upsd34xx instruction set summary 34/264 table 7. logical instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. mnemonic (1) and use description length/cycles logical instructions anl a, rn and register to acc 1 byte/1 cycle anl a, direct and direct byte to acc 2 byte/1 cycle anl a, @ri and indirect sram to acc 1 byte/1 cycle anl a, #data and immediate data to acc 2 byte/1 cycle anl direct, a and acc to direct byte 2 byte/1 cycle anl direct, #data and immediate data to direct byte 3 byte/2 cycle orl a, rn or register to acc 1 byte/1 cycle orl a, direct or direct byte to acc 2 byte/1 cycle orl a, @ri or indirect sram to acc 1 byte/1 cycle orl a, #data or immediate data to acc 2 byte/1 cycle orl direct, a or acc to direct byte 2 byte/1 cycle orl direct, #data or immediate data to direct byte 3 byte/2 cycle swap a swap nibbles within the acc 1 byte/1 cycle xrl a, rn exclusive-or register to acc 1 byte/1 cycle xrl a, direct exclusive-or direct byte to acc 2 byte/1 cycle xrl a, @ri exclusive-or indirect sram to acc 1 byte/1 cycle xrl a, #data exclusive-or immediate data to acc 2 byte/1 cycle xrl direct, a exclusive-or acc to direct byte 2 byte/1 cycle xrl direct, #data exclusive-or immediate data to direct byte 3 byte/2 cycle clr a clear acc 1 byte/1 cycle cpl a compliment acc 1 byte/1 cycle rl a rotate acc left 1 byte/1 cycle rlc a rotate acc left through the carry 1 byte/1 cycle rr a rotate acc right 1 byte/1 cycle rrc a rotate acc right through the carry 1 byte/1 cycle
35/264 upsd34xx - upsd34xx instruction set summary table 8. data transfer instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. mnemonic (1) and use description length/cycles mov a, rn move register to acc 1 byte/1 cycle mov a, direct move direct byte to acc 2 byte/1 cycle mov a, @ri move indirect sram to acc 1 byte/1 cycle mov a, #data move immediate data to acc 2 byte/1 cycle mov rn, a move acc to register 1 byte/1 cycle mov rn, direct move direct byte to register 2 byte/2 cycle mov rn, #data move immediate data to register 2 byte/1 cycle mov direct, a move acc to direct byte 2 byte/1 cycle mov direct, rn move register to direct byte 2 byte/2 cycle mov direct, direct move direct byte to direct 3 byte/2 cycle mov direct, @ri move indirect sram to direct byte 2 byte/2 cycle mov direct, #data move immediate data to direct byte 3 byte/2 cycle mov @ri, a move acc to indirect sram 1 byte/1 cycle mov @ri, direct move direct byte to indirect sram 2 byte/2 cycle mov @ri, #data move immediate data to indirect sram 2 byte/1 cycle mov dptr, #data16 load data pointer with 16-bit constant 3 byte/2 cycle movc a, @a+dptr move code byte relative to dptr to acc 1 byte/2 cycle movc a, @a+pc move code byte relative to pc to acc 1 byte/2 cycle movx a, @ri move xdata (8-bit addr) to acc 1 byte/2 cycle movx a, @dptr move xdata (16-bit addr) to acc 1 byte/2 cycle movx @ri, a move acc to xdata (8-bit addr) 1 byte/2 cycle movx @dptr, a move acc to xdata (16-bit addr) 1 byte/2 cycle xch a, rn exchange register with acc 1 byte/1 cycle push direct push direct byte onto stack 2 byte/2 cycle pop direct pop direct byte from stack 2 byte/2 cycle xch a, direct exchange direct byte with acc 2 byte/1 cycle xch a, @ri exchange indirect sram with acc 1 byte/1 cycle xchd a, @ri exchange low-order digit indi rect sram with acc 1 byte/1 cycle
upsd34xx - upsd34xx instruction set summary 36/264 table 9. boolean variable manipulation instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. mnemonic (1) and use description length/cycles clr c clear carry 1 byte/1 cycle clr bit clear direct bit 2 byte/1 cycle setb c set carry 1 byte/1 cycle setb bit set direct bit 2 byte/1 cycle cpl c compliment carry 1 byte/1 cycle cpl bit compliment direct bit 2 byte/1 cycle anl c, bit and direct bit to carry 2 byte/2 cycle anl c, /bit and compliment of direct bit to carry 2 byte/2 cycle orl c, bit or direct bit to carry 2 byte/2 cycle orl c, /bit or compliment of direct bit to carry 2 byte/2 cycle mov c, bit move direct bit to carry 2 byte/1 cycle mov bit, c move carry to direct bit 2 byte/2 cycle jc rel jump if carry is set 2 byte/2 cycle jnc rel jump if carry is not set 2 byte/2 cycle jb rel jump if direct bit is set 3 byte/2 cycle jnb rel jump if direct bit is not set 3 byte/2 cycle jbc bit, rel jump if direct bit is set and clear bit 3 byte/2 cycle
37/264 upsd34xx - upsd34xx instruction set summary table 10. program branching instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. table 11. miscellaneous instruction set note: 1. all mnemonics copyrighted ?intel corporation 1980. table 12. notes on instruction set and addressing modes mnemonic (1) and use description length/cycles program branching instructions acall addr11 absolute subroutine call 2 byte/2 cycle lcall addr16 long subroutine call 3 byte/2 cycle ret return from subroutine 1 byte/2 cycle reti return from interrupt 1 byte/2 cycle ajmp addr11 absolute jump 2 byte/2 cycle ljmp addr16 long jump 3 byte/2 cycle sjmp rel short jump (relative addr) 2 byte/2 cycle jmp @a+dptr jump indirect relative to the dptr 1 byte/2 cycle jz rel jump if acc is zero 2 byte/2 cycle jnz rel jump if acc is not zero 2 byte/2 cycle cjne a, direct, rel compare direct byte to acc, jump if not equal 3 byte/2 cycle cjne a, #data, rel compare immediate to acc, jump if not equal 3 byte/2 cycle cjne rn, #data, rel compare immediate to r egister, jump if not equal 3 byte/2 cycle cjne @ri, #data, rel compare immediate to i ndirect, jump if not equal 3 byte/2 cycle djnz rn, rel decrement register and jump if not zero 2 byte/2 cycle djnz direct, rel decrement direct byte and jump if not zero 3 byte/2 cycle mnemonic (1) and use description length/cycles miscellaneous nop no operation 1 byte/1 cycle rn register r0 - r7 of the cu rrently selected register bank. direct 8-bit address for internal 8032 data sram (locati ons 00h - 7fh) or sfr regi sters (locations 80h - ffh). @ri 8-bit internal 8032 sram (locations 00h - ffh) addressed indirectly through contents of r0 or r1. #data 8-bit constant included within the instruction. #data16 16-bit constant included within the instruction. addr16 16-bit destination address used by lcall and ljmp. addr11 11-bit destination address used by acall and ajmp. rel signed (two-s complim ent) 8-bit offset byte. bit direct addressed bit in internal 8032 data sram (loc ations 20h to 2fh) or in sfr registers (88h, 90h, 98h, a8h, b0, b8h, c0h, c 8h, d0h, d8h, e0h, f0h).
upsd34xx - dual data pointers 38/264 dual data pointers xdata is accessed by the external direct ad- dressing mode, which uses a 16-bit address stored in the dptr register. traditional 8032 ar- chitecture has only one dptr register. this is a burden when transferring data between two xda- ta locations because it requires heavy use of the working registers to manipulate the source and destination pointers. however, the upsd34xx has two data pointers, one for storing a source address and the other for storing a destination address. these pointers can be configured to automatically increment or decre- ment after each data transfer, further reducing the burden on the 8032 and making this kind of data movement very efficient. data pointer control register, dptc (85h) by default, the dptr register of the upsd34xx will behave no di fferent than in a standard 8032 mcu. the dpsel0 bit of sfr register dptc shown in table 13 , selects which one of the two ?background? data pointer registers (dptr0 or dptr1) will function as t he traditional dptr reg- ister at any given time. a fter reset, the dpsel0 bit is cleared, enabling dptr0 to function as the dp- tr, and firmware may access dptr0 by reading or writing the traditional dptr register at sfr ad- dresses 82h and 83h. when the dpsel0 bit is set, then the dptr1 register functions as dptr, and firmware may now access dptr1 through sfr registers at 82h and 83h. the pointer which is not selected by the dpsel0 bit remains in the back- ground and is not accessible by the 8032. if the dpsel0 bit is never se t, then the upsd34xx will behave like a traditional 8032 having only one dptr register. to further speed xdata to xdata transfers, the sfr bit, at, may be set to automatically toggle the two data pointers, dptr0 and dptr1, each time the standard dptr register is accessed by a movx instruction. this eliminates the need for firmware to manually manipulate the dpsel0 bit between each data transfer. detailed description for the sfr register dptc is shown in table 13 . table 13. dptc: data pointer control register (sfr 85h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 ?at?????d psel0 details bit symbol r/w definition 7 ? ? reserved 6atr,w 0 = manually select data pointer 1 = auto toggle between dptr0 and dptr1 5-1 ? ? reserved 0 dpse0 r,w 0 = dptr0 selected for use as dptr 1 = dptr1 selected for use as dptr
39/264 upsd34xx - dual data pointers data pointer mode register, dptm (86h) the two ?background? data pointers, dptr0 and dptr1, can be configured to automatically incre- ment, decrement, or stay the same after a movx instruction accesses the dp tr register. only the currently selected pointer will be affected by the in- crement or decrement. this feature is controlled by the dptm register defined in table 14 . the automatic increment or decrement function is effective only for the movx instruction, and not movc or any other instruction that uses the dtpr register. firmware example. the 8051 assembly code il- lustrated in table 15 shows how to transfer a block of data bytes from one xdata address region to another xdata address region. auto-address in- crementing and auto -pointer toggling will be used. table 14. dptm: data pointer mode register (sfr 86h, reset value 00h) table 15. 8051 assembly code example note: 1. the code loop where the data transfer takes place is only 3 lines of code. bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 ? ? ? ? md11 md10 md01 md00 details bit symbol r/w definition 7-4 ? ? reserved 3-2 md[11:10] r,w dptr1 mode bits 00: dptr1 no change 01: reserved 10: auto increment 11: auto decrement 1-0 md[01:00] r,w dptr0 mode bits 00: dptr0 no change 01: reserved 10: auto increment 11: auto decrement mov r7, #count ; initialize size of data block to transfer mov dptr, #source_addr ; load xdata source address base into dptr0 mov 85h, #01h ; load dptc to access dptr1 pointer mov dptr, #dest_addr ; load xdata destination address base into dptr1 mov 85h, #40h ; load dptc to acce ss dptr0 pointer and auto toggle mov 86h, #0ah ; load dptm to auto-increment both pointers loop: movx (1) a, @dptr ; load xdata byte from source into acc. ; after load completes, dptr0 increments and dptr ; switches dptr1 movx (1) @dptr, a ; store xdata byte from acc to destination. ; after store completes, dptr1 increments and dptr ; switches to dptr0 djnz (1) r7, loop ; continue until done mov 86h, #00 ; disable auto-increment mov 85h, #00 ; disable auto-toggle, now back to single dptr mode
upsd34xx - debug unit 40/264 debug unit the 8032 mcu module supports run-time debug- ging through the jtag interface. this same jtag interface is also used for in-system programming (isp) and the physical connections are described in the psd module section, jtag isp and jtag debug, page 226 . debugging with a serial interface such as jtag is a non-intrusive way to gain access to the internal state of the 8032 mcu core and various memo- ries. a traditional external hardware emulator can- not be completely effective on the upsd34xx because of the pre-fetch queue and branch cache. the nature of the pfq and bc hide the visibility of actual program flow through traditional external bus connections, thus requiring on-chip serial debugging instead. debugging is supported by windows pc based software tools used for 8051 code development from 3rd party vendors listed at www.st.com/psm. debug capabilities include: halt or start mcu execution reset the mcu single step 3 match breakpoints 1 range breakpoint (inside or outside range) program tracing read or modify mcu core registers, data, idata, sfr, xdata, and code external debug event pin, input or output some key points regarding use of the jtag de- bugger. ? the jtag debugger can access mcu registers, data memory, and code memory while the mcu is executing at full speed by cycle-stealing. this means ?watch windows? may be displayed and periodically updated on the pc during full speed operation. registers and data content may also be modified during full speed operation. ? there is no on-chip storage for program trace data, but instead this data is scanned from the upsd34xx through the jtag channel at run- time to the pc host for proccessing. as such, full speed program tracing is possible only when the 8032 mcu is operating below approximately one mips of performance. above one mips, the program will not run real-time while tracing. one mips performance is determined by the combination of choice for mcu clock frequency, and the bit settings in sfr registers buscon and ccon0. ? breakpoints can optionally halt the mcu, and/ or assert the external debug event pin. ? breakpoint definitions may be qualified with read or write operations, and may also be qualified with an address of code, sfr, data, idata, or xdata memories. ? three breakpoints will compare an address, but the fourth breakpoint can compare an address and also data content. additionally, the fouth breakpoint can be logically combined (and/or) with any of the other three breakpoints. ? the debug event pin can be configured by the pc host to generate an output pulse for external triggering when a break condition is met. the pin can also be configured as an event input to the breakpoint logic, causing a break on the falling-edge of an external event signal. if not used, the debug event pin should be pulled up to v cc as described in the section, debugging the 8032 mcu module., page 232 . ? the duration of a pulse, generated when the event pin configured as an output, is one mcu clock cycle. this is an active-low signal, so the first edge when an event occurs is high-to-low. ? the clock to the watchdog timer, adc, and i 2 c interface are not stopped by a breakpoint halt. ? the watchdog timer should be disabled while debugging with jtag, else a reset will be generated upon a watchdog time-out.
41/264 upsd34xx - interrupt system interrupt system the upsd34xx has an 12-source, two priority level interrupt structure summarized in table 16 . firmware may assign each interrupt source either high or low priority by wr iting to bits in the sfrs named, ip and ipa, shown in table 16 . an inter- rupt will be serviced as lo ng as an interrupt of equal or higher priority is not already being ser- viced. if an interrupt of equal or higher priority is being serviced, the new inte rrupt will wait until it is finished before being serv iced. if a lower priority interrupt is being servic ed, it will be stopped and the new interrupt is serv iced. when the new inter- rupt is finished, the lower priority interrupt that was stopped will be complete d. if new interrupt re- quests are of the same priority level and are re- ceived simultaneously, an internal polling sequence determines which request is selected for service. thus, within each of the two priority levels, there is a second priority structure deter- mined by the polling sequence. firmware may individually enable or disable inter- rupt sources by writing to bits in the sfrs named, ie and iea, shown in table 16., page 42 . the sfr named ie contains a global disable bit (ea), which can be cleared to disable all 12 interrupts at once, as shown in table 17., page 45 . figure 13., page 43 illustrates th e interrupt priority, poll- ing, and enabling process. each interrupt source has at least one interrupt flag that indicates whether or not an interrupt is pending. these flags reside in bits of various sfrs shown in table 16., page 42 . all of the interrupt flags are latched into the inter- rupt control system at the beginning of each mcu machine cycle, and they are polled at the begin- ning of the following machine cycle. if polling de- termines one of the flags was set, the interrupt control system automatically generates an lcall to the user?s interrupt service routine (isr) firm- ware stored in program memory at the appropriate vector address. the specific vector address for each of the inter- rupt sources are listed in table 16., page 42 . how- ever, this lcall jump may be blocked by any of the following conditions: ? an interrupt of equal or higher priority is already in progress ? the current machine cycle is not the final cycle in the execution of the instruction in progress ? the current instruction involves a write to any of the sfrs: ie, iea, ip, or ipa ? the current instruction is an reti note: interrupt flags are polled based on a sample taken in the previous mcu machine cycle. if an in- terrupt flag is active in one cycle but is denied ser- viced due to the conditions above, and then later it is not active when the conditions above are finally satisfied, the previously denied interrupt will not be serviced. this means that active interrupts are not remembered. every poling cycle is new. assuming all of the listed conditions are satisfied, the mcu executes the hardware generated lcall to the appropriate isr. this lcall pushes the contents of the pc onto the stack (but it does not save the psw) and loads the pc with the ap- propriate interrupt vector address. program exe- cution then jumps to the isr at the vector address. execution precedes in th e isr. it may be neces- sary for the isr firmware to clear the pending in- terrupt flag for some interrupt sources, because not all interrupt flags are automatically cleared by hardware when the isr is called, as shown in ta- ble 16., page 42 . if an interrupt flag is not cleared after servicing the interrupt, an unwanted interrupt will occur upon exiting the isr. after the interrupt is serv iced, the last instruction executed by the isr is reti. the reti informs the mcu that the isr is no longer in progress and the mcu pops the top two bytes from the stack and loads them into the pc. execution of the inter- rupted program continues where it left off. note: an isr must end with a reti instruction, not a ret. an ret will not inform the interrupt control system that the isr is complete, leaving the mcu to think the isr is still in progress, mak- ing future interrupts impossible.
upsd34xx - interrupt system 42/264 table 16. interrupt summary note: 1. see usb interrupt flag registers uif0-3. interrupt source polling priority vector addr flag bit name (sfr.bit position) 1 = intr pending 0 = no interrupt flag bit auto- cleared by hardware? enable bit name (sfr.bit position) 1 = intr enabled 0 = intr disabled priority bit name (sfr.bit position) 1= high priority 0 = low priority reserved 0 (high) 0063h ? ? ? ? external interrupt int0 1 0003h ie0 (tcon.1) edge - yes level - no ex0 (ie.0) px0 (ip.0) timer 0 overflow 2 000bh tf0 (tcon.5) yes et0 (ie.1) pt0 (ip.1) external interrupt int1 3 0013h ie1 (tcon.3 edge - yes level - no ex1 (ie.2) px1 (ip.2) timer 1 overflow 4 001bh tf1 (tcon.7) yes et1 (ie.3) pt1 (ip.3) uart0 5 0023h ri (scon0.0) ti (scon0.1) no es0 (ie.4) ps0 (ip.4) timer 2 overflow or tx2 pin 6 002bh tf2 (t2con.7) exf2 (t2con.6) no et2 (ie.5) pt2 (ip.5) spi 7 0053h teisf, rorisf, tisf, risf (spistat[3:0]) yes espi (iea.6) pspi (ipa.6) usb 8 0033h ? (1) no eusb (iea.0) pusb (ipa.0) i 2 c 9 0043h intr (s1sta.5) yes ei 2 c (iea.1) pi 2 c (ipa.1) adc 10 003bh aintf (acon.7) no eadc (iea.7) padc (ipa.7) pca 11 005bh ofvx, intfx (pcasta[0:7]) no epca (iea.5) ppca (ipa.5) uart1 12 (low) 004bh ri (scon1.0) ti (scon1.1) no es1 (iea.4) ps1 (ipa.4)
43/264 upsd34xx - interrupt system figure 13. enabling and polling interrupts reserved ext int0 ext int1 timer 0 uart0 timer 1 spi usb timer 2 high low interrupt polling sequence interrupt sources ie/iea ip/ipa priority global enable adc pca i 2 c uart1 ai07844
upsd34xx - interrupt system 44/264 individual interrupt sources external interrupts int0 and int1. external in- terrupt inputs on pins extint0 and extint1 (pins 3.2 and 3.3) are either edge-triggered or lev- el-triggered, depending on bits it0 and it1 in the sfr named tcon. when an external interrupt is generated from an edge-triggered (falling-ed ge) source, the appropri- ate flag bit (ie0 or ie1) is automatically cleared by hardware upon entering the isr. when an external interrupt is generated from a level-triggered (low-level) source, the appropriate flag bit (ie0 or ie1) is not automatically cleared by hardware. timer 0 and 1 overflow interrupt. timer 0 and timer 1 interrupts are generated by the flag bits tf0 and tf1 when there is an overflow condition in the respective timer/counter register (except for timer 0 in mode 3). timer 2 overflow interrupt. this interrupt is generated to the mcu by a logical or of flag bits, tf2 and exe2. the isr must read the flag bits to determine the cause of the interrupt. ? tf2 is set by an overflow of timer 2. ? exe2 is generated by the falling edge of a signal on the external pin, t2x (pin p1.1). uart0 and uart1 interrupt. each of the uarts have identical inte rrupt structure. for each uart, a single interrupt is generated to the mcu by the logical or of the flag bits, ri (byte received) and ti (byte transmitted). the isr must read flag bits in the sfr named scon0 for uart0, or scon1 for uart1 to de- termine the cause of the interrupt. spi interrupt. the spi interrupt has four interrupt sources, which are logically ored together when interrupting the mcu. the isr must read the flag bits to determine the cause of the interrupt. a flag bit is set for: end of data transmit (teisf); data receive overrun (rorisf); transmit buffer empty (tisf); or receive buffer full (risf). i 2 c interrupt. the flag bit intr is set by a variety of conditions occurring on the i 2 c interface: re- ceived own slave address (addr flag); received general call address (gc flag); received stop condition (stop flag); or successful transmission or reception of a data byte.the isr must read the flag bits to determine the cause of the interrupt. adc interrupt. the flag bit aintf is set when an a-to-d conversion has completed. pca interrupt. the pca has eight interrupt sources, which are logically ored together when interrupting the mcu.the isr must read the flag bits to determine the cause of the interrupt. ? each of the six tcms can generate a "match or capture" interrupt on flag bits ofv5..0 respectively. ? each of the two 16-bit counters can generate an overflow interrupt on flag bits intf1 and intf0 respectively. tables 17 through table 20., page 46 have de- tailed bit definitions of the interrupt system sfrs. usb interrupt. the usb interrupt has multiple sources. the isr must read the usb interrupt flag registers (uif0-3) to determine the source of the interrupt. the usb interrupt can be activated by any of the following four group of interrupt sources: ? global: the interrupt flag is set when any of the following events occu rs: usb reset, usb suspend, usb resume, and end of packet; ? in fifo: the interrupt flag is set when any of the end point in fifo becomes empty; ? out fifo: the interrupt flag is set when any of the end point out fifo becomes full; and ? in fifo nak: the interrupt flag is set when any of the end point in fifo is not ready for an in (in-bound) packet.
45/264 upsd34xx - interrupt system table 17. ie: interrupt enable register (sfr a8h, reset value 00h) note: 1. 1 = enable interrupt, 0 = disable interrupt table 18. iea: interrupt enable additi on register (sfr a7h, reset value 00h) note: 1. 1 = enable interrupt, 0 = disable interrupt bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 ea ? et2 es0 et1 ex1 et0 ex0 details bit symbol r/w function 7ear,w global disable bit. 0 = all interrupts are disabled. 1 = each interrupt source can be individually enabled or disabled by setting or clearing its enable bit. 6?r,w do not modify this bit. it is used by the jtag debugger for instruction tracing. always read the bit and wr ite back the same bit value when writing this sfr. 5 (1) et2 r,w enable timer 2 interrupt 4 (1) es0 r,w enable uart0 interrupt 3 (1) et1 r,w enable timer 1 interrupt 2 (1) ex1 r,w enable external interrupt int1 1 (1) et0 r,w enable timer 0 interrupt 0 (1) ex0 r,w enable external interrupt int0 bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 eadc espi epca es1 ? ? ei 2 c eusb details bit symbol r/w function 7 (1) eadc r,w enable adc interrupt 6 (1) espi r,w enable spi interrupt 5 (1) epca r,w enable programmable counter array interrupt 4 (1) es1 r,w enable uart1 interrupt 3 ? ? reserved, do not set to logic '1.' 2 ? ? reserved, do not set to logic '1.' 1 (1) ei 2 c r,w enable i 2 c interrupt 0 eusb r,w enable usb interrupt
upsd34xx - interrupt system 46/264 table 19. ip: interrupt priority register (sfr b8h, reset value 00h) note: 1. 1 = assigns high priority level, 0 = assigns low priority level table 20. ipa: interrupt priority addition register (sfr b7h, reset value 00h) note: 1. 1 = assigns high priority level, 0 = assigns low priority level bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 ? ? pt2 ps0 pt1 px1 pt0 px0 details bit symbol r/w function 7 ? ? reserved 6 ? ? reserved 5 (1) pt2 r,w timer 2 interrupt priority level 4 (1) ps0 r,w uart0 interrupt priority level 3 (1) pt1 r,w timer 1 interrupt priority level 2 (1) px1 r,w external interrupt int1 priority level 1 (1) pt0 r,w timer 0 interrupt priority level 0 (1) px0 r,w external interrupt int0 priority level bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 padc pspi ppca ps1 ? ? pi 2 c pusb details bit symbol r/w function 7 (1) padc r,w adc interrupt priority level 6 (1) pspi r,w spi interrupt priority level 5 (1) ppca r,w pca interrupt level 4 (1) ps1 r,w uart1 interrupt priority level 3 ? ? reserved 2 ? ? reserved 1 (1) pi 2 c r,w i 2 c interrupt priority level 0 pusb r,w usb interrupt priority level
47/264 upsd34xx - mcu clock generation mcu clock generation internal system clocks generated by the clock gen- eration unit are derived from the signal, xtal1, shown in figure 14 . xtal1 has a frequency f osc , which comes directly from the external crystal or oscillator device. th e sfr named ccon0 ( table 22., page 49 ) controls the clock generation unit. there are two clock signals produced by the clock generation unit: mcu_clk periph_clk mcu_clk this clock drives the 8032 mcu core and the watchdog timer (wdt). the frequency of mcu_clk is equal to f osc by default, but it can be divided by as much as 2048, shown in figure 14 . the bits cpups[2:0] select one of eight different divisors, ranging from 2 to 2048. the new frequen- cy is available immediately after the cpups[2:0] bits are written. the final frequency of mcu_clk is f mcu . mcu_clk is blocked by either bit, pd or idl, in the sfr named pcon during mcu power-down mode or idle mode respectively. mcu_clk clock can be further divided as re- quired for use in the wdt. see details of the wdt in supervisory functions, page 67 . periph_clk this clock drives all the upsd34xx peripherals ex- cept the wdt. the frequency of periph_clk is always f osc . each of the peripherals can indepen- dently divide periph_clk to scale it appropriate- ly for use. periph_clk runs at all times except when blocked by the pd bit in the sfr named pcon during mcu power-down mode. jtag interface clock. the jtag interface for isp and for debugging uses the externally sup- plied jtag clock, coming in on pin tck. this means the jtag isp interface is always available, and the jtag debug interface is available when enabled, even during mcu idle mode and power- down mode. however, since the mcu participates in the jtag debug process, and mcu_clk is halted during idle and power-down mode s, the majority of de- bug functions are not available during these low power modes. but the jtag debug interface is ca- pable of executing a reset command while in these low power modes, which will exit back to normal operating mode where all debug commands are available again. the ccon0 sfr contains a bit, dbgce, which enables the breakpoint comparators inside the jtag debug unit when se t. dbgce is set by de- fault after reset, and firmware may clear this bit at run-time. disabling thes e comparators will reduce current consumption on the mcu module, and it is recommended to do so if the debug unit will not be used (such as in the production version of an end-product). usb_clk. the upsd34xx has a dedicated ana- log phase locked loop (pll) that can be config- ured to generate the 48mhz usb_clk clock on a wide range of f osc frequencies. the usb_clk must be at 48mhz for the usb to function proper- ly. the pll is enabled after power up. the power on lock time for the pll clock is about 200s, and the firmware should wait that much time before en- abling the usb_clk by setting the usbce bit in the ccon0 register to '1.' the pll is disabled in power-down mode, it can also be disabled or en- abled by writing to the pllen bit in the ccon0 register. the pll output clock frequency (f usb_clk ) can be determined by using the following formula: where pllm and plld are the multiplier and divi- sor that are specified in the ccon1 register. the f osc , the pllm and plld range must meet the following conditions to generate a stable usb_clk: a. ?1 pllm 30 (binary: [11111] pllm[4:0] [11110]), b. ?1 plld 14 (binary: [1111] plld[3:0] [1110]), and c. f osc /(plld+2) must be equal to or greater than 3mhz. the usb requires a 48mhz clock to operate cor- rectly. the pllm[4:0] and plld[3:0] values must be selected so as to generate a usb_clk that is as close to 48mhz as possible at different oscilla- tor frequencies (f osc ). table 21., page 48 lists some of the pllm and plld values that can be used on common f osc frequencies. f usbclk f osc pllm 2 + () [] plld 2 + () 2 [] ? =
upsd34xx - mcu clock generation 48/264 table 21. pllm and plld values for different f osc frequencies figure 14. clock generation logic f osc (mhz) pllm[4:0] plld[3:0] f usb_clk (mhz) decimal binary decimal binary 40.0 22 10110 8 1000 48.0 36.0 6 00110 1 0001 48.0 33.0 30 11110 9 1001 48.0 30.0 14 01110 3 0011 48.0 24.0 18 10010 3 0011 48.0 16.0 28 11100 3 0011 48.0 12.0 30 11110 2 0010 48.0 8.0 22 10110 0 0000 48.0 6.0 30 11110 0 0000 48.0 3.0 30 11110 ?1 1111 48.0 xtal1 /2 xtal1 /4 xtal1 /2048 q q q m u x xtal1 (default) xtal1 /8 xtal1 /16 q q xtal1 /32 xtal1 /1024 q q 0 1 2 3 4 5 6 7 clk pll en xtal1 (f osc ) pcon[1] ccon0[6] pcon[1]: pd, power-down mode pcon[2:0]: cpups[2:0], clock pre-scaler select pcon[0]: idl, idle mode clock divider mcu_clk (f mcu ) (to: 8032, wdt) periph_clk (f osc ) (to: timer0/1/2, uart0/1, pca0/1, spi, i2c, adc) usb_clk 3 ai10433
49/264 upsd34xx - mcu clock generation table 22. ccon0: clock control register (sfr f9h, reset value 50h) table 23. ccon1 pll control register (sfr fah, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 pllm[4] pllen upllce dbgce cpuar cpups[2:0] details bit symbol r/w definition 7 pllm[4] r,w upper bit of the 5-bit pllm[4:0 ] multiplier (default: '0' for pllm = 00h) 6 pllen r,w pll enable 0 = disable pll operation 1 = enable pll operation (default condition after reset) 5 upllce r,w usb clock enable 0 = usb clock is disabled (default condition after reset) 1 = usb clock is enabled 4 dbgce r,w debug unit breakpoint comparator enable 0 = jtag debug unit comparators are disabled 1 = jtag debug unit comparators are enabled (default condition after reset) 3 cpuar r,w automatic mcu clock recovery 0 = there is no change of cpups[2:0] when an interrupt occurs. 1 = contents of cpups[2:0] automatically become 000b whenever any interrupt occurs. 2:0 cpups r,w mcuclk pre-scaler 000b: f mcu = f osc (default after reset) 001b: f mcu = f osc /2 010b: f mcu = f osc /4 011b: f mcu = f osc /8 100b: f mcu = f osc /16 101b: f mcu = f osc /32 110b: f mcu = f osc /1024 111b: f mcu = f osc /2048 bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 pllm[3:0] plld[3:0] details bit symbol r/w definition 7:4 pllm[3:0] r,w lower 4 bits of the 5- bit pllm[4:0] multiplier (default after reset: pllm = 00h) pllm[4] is in the ccon0 register. 3:0 plld[3:0] r,w 4-bit pll divider (d efault after reset: plld = 0h)
upsd34xx - power saving modes 50/264 power saving modes the upsd34xx is a combination of two die, or modules, each module having its own current con- sumption characteristics. this section describes reduced power modes for the mcu module. see the section, power management, page 168 for re- duced power modes of the psd module. total cur- rent consumption for the combined modules is determined in the dc specifications at the end of this document. the mcu module has three software-selectable modes of reduced power operation. idle mode power-down mode reduced frequency mode idle mode idle mode will halt the 80 32 mcu core while leav- ing the mcu peripherals active (idle mode blocks mcu_clk only). for lowest current consumption in this mode, it is recommended to disable all un- used peripherals, before entering idle mode (such as the adc and the debug unit breakpoint com- parators). the following functions remain fully ac- tive during idle mode (except if disabled by sfr settings). external interrupts int0 and int1 timer 0, timer 1 and timer 2 supervisor reset from: lvd, jtag debug, external reset_in_, but not the wtd adc i 2 c interface uart0 and uart1 interfaces spi interface programmable counter array usb interface an interrupt generated by any of these peripher- als, or a reset generated from the supervisor, will cause idle mode to exit and the 8032 mcu will re- sume normal operation. the output state on i/o pins of mcu ports 1, 3, and 4 remain unchanged during idle mode. to enter idle mode, the 8032 mcu executes an in- struction to set the idl bit in the sfr named pcon, shown in table 26., page 52 . this is the last instruction executed in normal operating mode before idle mode is activated. once in idle mode, the mcu status is entirely preserved, and there are no changes to: sp, psw, pc, acc, sfrs, data, idata, or xdata. the following are factors related to idle mode exit: ? activation of any enabl ed interrupt will cause the idl bit to be cleared by hardware, terminating idle mode. the interrupt is serviced, and following the return from interrupt instruction (reti), the next instruction to be exec uted will be the one which follows the instruction that set the idl bit in the pcon sfr. ? after a reset from the supervisor, the idl bit is cleared, idle mode is terminated, and the mcu restarts after thr ee mcu machine cycles. power-down mode power-down mode will halt t he 8032 core and all mcu peripherals (power-down mode blocks mcu_clk, usb_clk, and periph_clk). this is the lowest power st ate for the mcu module. when the psd module is also placed in power- down mode, the lowest total current consumption for the combined die is achieved for the upsd34xx. see power management, page 168 in the psd module section for details on how to also place the psd module in power-down mode. the sequence of 8032 instructions is important when placing both modules into power-down mode. the instruction that sets the pd bit in the sfr named pcon ( table 26., page 52 ) is the last in- struction executed prior to the mcu module going into power-down mode. once in power-down mode, the on-chip oscillato r circuitry and all clocks are stopped. the sfrs, data, idata, and xdata are preserved. power-down mode is terminated only by a reset from the supervisor, originating from the reset_in_ pin, the low-voltage detect circuit (lvd), or a jtag debug reset command. since the clock to the wtd is not active during power- down mode, it is not possible for the supervisor to generate a wdt reset. table 24., page 51 summarizes the status of i/o pins and peripherals during idle and power-down modes on the mcu module. table 25., page 51 shows the state of 8032 mcu address, data, and control signals during these modes. reduced frequency mode the 8032 mcu consumes less current when oper- ating at a lower clock frequency. the mcu can re- duce its own clock frequency at run-time by writing to three bits, cpups[2:0], in the sfr named ccon0 described in table 22., page 49 . these bits effectively divide the clock frequency (f osc ) coming in from the external crystal or oscillator de- vice. the clock division range is from 1/2 to 1/ 2048, and the resulting frequency is f mcu . this mcu clock division does not affect any of the peripherals, except for the wtd. the clock driving the wtd is the same clock driving the 8032 mcu core as shown in figure 14., page 48 .
51/264 upsd34xx - power saving modes mcu firmware may reduce the mcu clock fre- quency at run-time to consume less current when performing tasks that are not time critical, and then restore full clock frequency as required to perform urgent tasks. returning to full clock frequency is done automat- ically upon an mcu interrupt, if the cpuar bit in the sfr named ccon0 is set (the interrupt will force cpups[2:0] = 000). th is is an excellent way to conserve power using a low frequency clock un- til an event occurs that requires full performance. see table 22., page 49 for details on cpuar. see the dc specifications at the end of this docu- ment to estimate current consumption based on the mcu clock frequency. note: some of the bits in the pcon sfr shown in table 26., page 52 are not related to power con- trol. table 24. mcu module port and peripheral status during reduced power modes note: 1. the watchdog timer is not active during idle mode. other supervisor functions are active: lvd, external reset, jtag debu g reset. table 25. state of 8032 mcu bus signals during power-down and idle modes mode ports 1, 3, 4 spi, i 2 c, uart0,1 pca, timer 0,1,2 usb adc ext int0,1 super- visory idle maintain data active active active active active active (1) power-down maintain data disabled disabled disabled disabled disabled disabled mode ale psen_ rd_ wr_ ad0-7 a8-15 idle0111ffhffh power-down0111ffhffh
upsd34xx - power saving modes 52/264 table 26. pcon: power control register (sfr 87h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 smod0 smod1 ? por rclk1 tclk1 pd idl details bit symbol r/w function 7 smod0 r,w baud rate double bit (uart0) 0 = no doubling 1 = doubling (see uart baud rates, page 86 for details.) 6 smod1 r,w baud rate double bit for 2nd uart (uart1) 0 = no doubling 1 = doubling (see uart baud rates, page 86 for details.) 5??reserved 4porr,w only a power-on reset sets this bit (cold reset). warm reset will not set this bit. '0,' cleared to zero with firmware '1,' is set only by a power-on reset generated by supervisory circuit (see power-up reset, page 68 for details). 3 rclk1 r,w received clock flag (uart1) (see table 43., page 77 for flag description.) 2 tclk1 r,w transmit clock flag (uart1) (see table 43., page 77 for flag description) 1pdr,w activate power-down mode 0 = not in power-down mode 1 = enter power-down mode 0idlr,w activate idle mode 0 = not in idle mode 1 = enter idle mode
53/264 upsd34xx - oscillator and external components oscillator and external components the oscillator circuit of upsd34xx devices is a sin- gle stage, inverting amplif ier in a pierce oscillator configuration. the internal circuitry between pins xtal1 and xtal2 is basically an inverter biased to the transfer point. either an external quartz crys- tal or ceramic resonator can be used as the feed- back element to complete the oscillator circuit. both are operated in parallel resonance. ceramic resonators are lower cost, but typically have a wid- er frequency tolerance than quartz crystals. alter- natively, an external clock source from an oscillator or other active device may drive the upsd34xx oscillator circuit input direct ly, instead of using a crystal or resonator. the minimum frequency of the quartz crystal, ce- ramic resonator, or external clock source is 3mhz if the usb is used. the minimum is 8mhz if i 2 c is used. the maximum is 40mhz in all cases. this frequency is f osc , which can be divided internally as described in mcu clock generation, page 47 . the pin xtal1 is the high gain amplifier input, and xtal2 is the output. to drive the upsd34xx de- vice externally from an oscillator or other active device, xtal1 is driven and xtal2 is left open- circuit. this external source should drive a logic low at the voltage level of 0.3 v cc or below, and logic high at 0.7v v cc or above, up to 5.5v v cc . the xtal1 input is 5v tolerant. most of the quartz crystals in the range of 25mhz to 40mhz operate in the third overtone frequency mode. an external lc tank circuit at the xtal2 output of the oscillator circ uit is needed to achieve the third overtone frequency, as shown in figure 15., page 53 . without this lc circuit, the crystal will oscillate at a fundamen tal frequency mode that is about 1/3 of the desired overtone frequency. note: in figure 15., page 53 crystals which are specified to operate in fundamental mode (not overtone mode) do not need the lc circuit compo- nents. since quartz crystals and ceramic resona- tors have their own characteristics based on their manufacturer, it is wise to also consult the manu- facturer?s recommended values for external com- ponents. figure 15. oscillator and clock connections crystal or resonator usage direct drive xtal1 (in) xtal1 (in) xtal2 (out) xtal2 (out) c1 c2 xtal (f osc ) l1 c3 no connect external ocsillator or active clock source xtal (f osc ) c1 = c2 c3 l1 ceramic resonator 40 - 50pf none crystal, fundamental mode (3-40mhz) 15-33pf none none none crystal, overtone mode (25-40mhz) 20pf 10nf 2.2h ai09198
upsd34xx - i/o ports of mcu module 54/264 i/o ports of mcu module the mcu module has three 8-bit i/o ports: port 1, port 3, and port 4. the psd module has four other i/o ports: port a, b, c, and d. this section de- scribes only the i/o ports on the mcu module. i/o ports will function as bi-directional general purpose i/o (gpio), but the port pins can have al- ternate functions assigned at run-time by writing to specific sfrs. the default operating mode (during and after reset) for all three ports is gpio input mode. port pins that have no external connection will not float because each pin has an internal weak pull-up (~150k ohms) to v cc . i/o ports 3 and 4 are 5v tolerant, meaning they can be driven/pulled externally up to 5.5v without damage. the pins on port 4 have a higher current capability than the pins on ports 1 and 3. three additional mcu ports (only on 80-pin upsd34xx devices) are dedicated to bring out the 8032 mcu address, data, and control signals to external pins. one port, named mcuad[7:0], has eight multiplexed address/data bidirectional sig- nals. the third port has mcu bus control outputs: read, write, program fetch, and address latch. these ports are typically used to connect external parallel peripherals and memory devices, but they may not be used as gpio. notice that the eight upper address signals do not come out to pins on the port. if high-order address signals are required on external pins (mcu addresses a[15:8]), then these address signals can be brought out as need- ed to pld output pins or to the address out mode pins on psd module ports. see psd module sec- tion, ? latched address output mode, page 208 for details. figure 16., page 56 represents the flexibility of pin function routing controlled by the sfrs. each of the 24 pins on three ports, p1, p3, and p4, may be individually routed on a pin-by-pin basis to a de- sired function. mcu port operating modes mcu port pins can operate as gpio or as alter- nate functions (see figure 17., page 57 through figure 19., page 58 ). depending on the selected pin function, a particu- lar pin operating mode will automatically be used: gpio - quasi-bidirectional mode uart0, uart1 - quas i-bidirectional mode spi - quasi-bidirectional mode i2c - open drain mode adc - analog input mode pca output - push-pull mode pca input - input only (quasi-bidirectional) timer 0,1,2 - input only (quasi-bidirectional) gpio function. ports in gpio mode operate as quasi-bidirectional pins, consistent with standard 8051 architecture. gpio pins are individually con- trolled by three sfrs: sfr, p1 ( table 27., page 58 ) sfr, p3 ( table 28., page 59 ) sfr, p4 ( table 29., page 59 ) these sfrs can be accessed using the bit ad- dressing mode, an efficient way to control individ- ual port pins. gpio output. simply stated, when a logic '0' is written to a bit in any of these port sfrs while in gpio mode, the correspon ding port pin will enable a low-side driver, which pulls the pin to ground, and at the same time releases the high-side driver and pull-ups, resulting in a logic '0' output. when a logic '1' is written to the sfr, the low-side driver is released, the high-side driver is enabled for just one mcu_clk period to rapidly make the 0-to1 transition on the pin, while weak active pull-ups (total ~150k ? ) to v cc are enabled. this structure is consistent with standard 8051 architecture. the high side driver is momentarily enabled only for 0- to-1 transitions, which is implemented with the de- lay function at the latch output as pictured in fig- ure 17., page 57 , figure 18., page 57 , and figure 19., page 58 . after the high-side driver is disabled, the two weak pull-ups rema in enabled resulting in a logic '1' output at the pin, sourcing i oh ua to an external device. optionally, an external pull-up re- sistor can be added if additional source current is needed while outputting a logic '1.'
55/264 upsd34xx - i/o ports of mcu module gpio input. to use a gpio port pin as an input, the low-side driver to ground must be disabled, or else the true logic level being driven on the pin by an external device will be masked (always reads logic '0'). so to make a port pin ?input ready?, the corresponding bit in the sfr must have been set to a logic '1' prior to reading that sfr bit as an in- put. a reset condition forces sfrs p1, p3, and p4 to ffh, thus all three ports are input ready after re- set. when a pin is used as an input, the stronger pull- up ?a? maintains a solid logic '1' until an external device drives the input pin low. at this time, pull-up ?a? is automatically disabled, and only pull-up ?b? will source the external device i ih ua, consistent with standard 8051 architecture. gpio bi-directional. it is possible to operate indi- vidual port pins in bi-directional mode. for an out- put, firmware would simply write the corresponding sfr bit to logic '1' or '0' as needed. but before using the pin as an input, firmware must first ensure that a logic '1' was the last value writ- ten to the corresponding sfr bit prior to reading that sfr bit as an input. gpio current capability. a gpio pin on port 4 can sink twice as much current than a pin on either port 1 or port 3 when the low-side driver is output- ting a logic '0' (i ol ). see the dc specifications at the end of this document for full details. reading port pin vs. reading port latch. when firmware reads the gpio ports, sometimes the ac- tual port pin is sampled in hardware, and some- times the port sfr latch is read and not the actual pin, depending on the type of mcu instruction used. these two data paths are shown in figure 17., page 57 through figure 19., page 58 . sfr latches are read (and not the pins) only when the read is part of a read-modify-write instruction and the write destination is a bit or bits in a port sfr. these instructions are: anl, orl, xrl, jbc, cpl, inc, dec, djnz, mov, clr, and setb. all other types of reads to port sfrs will read the ac- tual pin logic level and not the port latch. this is consistent with 8051 architecture.
upsd34xx - i/o ports of mcu module 56/264 figure 16. mcu module port pin function routing 8 p3 p1 p4 m c u a d gpio (8) uart0 (2) timer0/1 (4) i 2 c (2) gpio (8) gpio (8) timer2 (2) uart1 (2) spi (4) adc (8) pca (8) 8032 mcu core low addr & data[7:0] 8 hi address [15:8] (available on psd module pins) mcu module 8 on 80-pin devices only ports c n t l rd, wr, psen, ale 4 sfr 8 8 sfr sfr sfr sfr sfr ai09199b
57/264 upsd34xx - i/o ports of mcu module figure 17. mcu i/o cell bl ock diagram for port 1 figure 18. mcu i/o cell bl ock diagram for port 3 p1.x pin analog_alt_func_en analog_pin_in q d pre sfr p1.x latch 8032 data bus bit gpio p1.x sfr write latch mcu_reset p1.x sfr read latch (for r-m-w instructions) p1.x sfr read pin select_alternate_func digital_pin_data_in in 1 in 0 y mux v cc v cc v cc sel weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09600 p3.x pin digital_pin_data_in q d pre sfr p3.x latch 8032 data bus bit gpio p3.x sfr write latch mcu_reset p3.x sfr read latch (for r-m-w instructions) p3.x sfr read pin select_alternate_func disables high-side driver in 1 in 0 y mux v cc v cc v cc sel enable_i 2 c weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09601
upsd34xx - i/o ports of mcu module 58/264 figure 19. mcu i/o cell bl ock diagram for port 4 table 27. p1: i/o port 1 register (sfr 90h, reset value ffh) note: 1. write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware o r by a reset event. bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 details bit symbol r/w function (1) 7 p1.7 r,w port pin 1.7 6 p1.6 r,w port pin 1.6 5 p1.5 r,w port pin 1.5 4 p1.4 r,w port pin 1.4 3 p1.3 r,w port pin 1.3 2 p1.2 r,w port pin 1.2 1 p1.1 r,w port pin 1.1 0 p1.0 r,w port pin 1.0 p4.x pin digital_pin_data_in q d pre sfr p4.x latch 8032 data bus bit gpio p4.x sfr write latch mcu_reset p4.x sfr read latch (for r-m-w instructions) p4.x sfr read pin select_alternate_func for pca alternate function in 1 in 0 y mux v cc v cc v cc sel enable_push_pull weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09602
59/264 upsd34xx - i/o ports of mcu module table 28. p3: i/o port 3 regist er (sfr b0h, reset value ffh) note: 1. write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware o r by a reset event. table 29. p4: i/o port 4 regist er (sfr c0h, reset value ffh) note: 1. write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware o r by a reset event. bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 details bit symbol r/w function (1) 7 p3.7 r,w port pin 3.7 6 p3.6 r,w port pin 3.6 5 p3.5 r,w port pin 3.5 4 p3.4 r,w port pin 3.4 3 p3.3 r,w port pin 3.3 2 p3.2 r,w port pin 3.2 1 p3.1 r,w port pin 3.1 0 p3.0 r,w port pin 3.0 bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 details bit symbol r/w function (1) 7 p4.7 r,w port pin 4.7 6 p4.6 r,w port pin 4.6 5 p4.5 r,w port pin 4.5 4 p4.4 r,w port pin 4.4 3 p4.3 r,w port pin 4.3 2 p4.2 r,w port pin 4.2 1 p4.1 r,w port pin 4.1 0 p4.0 r,w port pin 4.0
upsd34xx - i/o ports of mcu module 60/264 alternate functions. there are five sfrs used to control the mapping of alternate functions onto mcu port pins, and these sfrs are depicted as switches in figure 16., page 56 . port 3 uses the sfr, p3sfs ( table 30., page 61 ). port 1 uses sfrs, p1sfs0 ( table 31., page 61 ) and p1sfs1 ( table 32., page 61 ). port 4 uses sfrs, p4sfs0 ( table 34., page 62 ) and p4sfs1 ( table 35., page 62 ). since these sfrs are cleared by a reset, then by default all port pins function as gpio (not the alter- nate function) until firmware initializes these sfrs. each pin on each of the three ports can be inde- pendently assigned a different function on a pin- by-pin basis. the peripheral functions timer 2, uart1, and i 2 c may be split independently between port 1 and port 4 for additional flexibility by giving a wider choice of peripheral usage on a limited number of device pins. when the selected alternate function is uart0, uart1, or spi, then the related pins are in quasi- bidirectional mode, including the use of the high- side driver for rapid 0-to-1 output transitions. the high-side driver is enabled for just one mcu_clk period on 0-to-1 transitions by the delay function at the ?digital_alt_func_data_out? signal pictured in figure 17., page 57 through figure 19., page 58 . if the alternate function is timer 0, timer 1, timer 2, or pca input, then the related pins are in quasi- bidirectional mode, but input only. if the alternate function is adc, then for each pin the pull-ups, the high-side driver, and the low-side driver are disabled. the analog input is routed di- rectly to the adc unit. only port 1 supports analog functions ( figure 17., page 57 ). port 1 is not 5v tolerant. if the alternate function is i 2 c, the related pins will be in open drain mode, which is just like quasi-bi- directional mode but the high-side driver is not en- abled for one cycle when outputting a 0-to-1 transition. only the low-side driver and the internal weak pull-ups are used. only port 3 supports open-drain mode ( figure 18., page 57 ). i 2 c re- quires the use of an external pull-up resistor on each bus signal, typically 4.7k ? to v cc . if the alternate function is pca output, then the re- lated pins are in push-pull mode, meaning the pins are actively driven and held to logic '1' by the high- side driver, or actively driven and held to logic '0' by the low-side driver. only port 4 supports push- pull mode ( figure 19., page 58 ). port 4 push-pull pins can source i oh current when driving logic '1,' and sink i ol current when driving logic '0.' this current is significantly more than the capability of pins on port 1 or port 3 (see table 156., page 238 ). for example, to assign these port functions: port 1: uart1, adc[1:0], p1[7:4] are gpio port 3: uart0, i 2 c, p3[5:2] are gpio port 4: tcm0, spi, p4[3:1] are gpio the following values need to be written to the sfrs: p1sfs0 = 00001111b, or 0fh p1sfs1 = 00000011b , or 03h p3sfs = 11000011b, or c3h p4sfs0 = 11110001b, or f1h p4sfs1 = 11110000b, or f0h
61/264 upsd34xx - i/o ports of mcu module table 30. p3sfs: port 3 special function select register (sfr 91h, reset value 00h) table 31. p1sfs0: port 1 special function sele ct 0 register (sfr 8eh, reset value 00h) table 32. p1sfs1: port 1 special function sele ct 1 register (sfr 8fh, reset value 00h) table 33. p1sfs0 and p1sfs1 details bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p3sfs7 p3sfs6 p3sfs5 p3sfs4 p3sfs3 p3sfs2 p3sfs1 p3sfs0 details port 3 pin r/w default port function alternate port function p3sfs[i] - 0; port 3 pin, i = 0..7 p3sfs[i] - 1; port 3 pin, i = 0..7 0 r,w gpio uart0 receive, rxd0 1 r,w gpio uart0 transmit, txd0 2 r,w gpio ext intr 0/timer 0 gate, ext0int/tg0 3 r,w gpio ext intr 1/timer 1 gate, ext1int/tg1 4 r,w gpio counter 0 input, c0 5 r,w gpio counter 0 input, c1 6r,w gpio i 2 c data, i2csda 7r,w gpio i 2 c clock, i2ccl bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p1sf07 p1sf06 p1sf05 p1sf04 p1sf03 p1sf02 p1sf01 p1sf00 details bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p1sf17 p1sf16 p1sf15 p1sf14 p1sf13 p1sf12 p1sf11 p1sf10 port 1 pin r/w default port function alternate 1 port function alternate 2 port function p1sfs0[i] = 0 p1sfs1[i] = x p1sfs0[i] = 1 p1sfs1[i] = 0 p1sfs0[i] = 1 p1sfs1[i] = 1 port 1 pin, i = 0.. 7 port 1 pin, i = 0.. 7 port 1 pin, i = 0.. 7 0 r,w gpio timer 2 count input, t2 adc chn 0 input, adc0 1 r,w gpio timer 2 trigger input, tx2 adc chn 1 input, adc1 2 r,w gpio uart1 receive, rxd1 adc chn 2 input, adc2 3 r,w gpio uart1 transmit, txd1 adc chn 3 input, adc3 4 r,w gpio spi clock, spiclk adc chn 4 input, adc4 5 r,w gpio spi receive, spirxd adc chn 5 input, adc5 6 r,w gpio spi transmit, spitxd adc chn 6 input, adc6 7 r,w gpio spi select, spisel_ adc chn 7 input, adc7
upsd34xx - i/o ports of mcu module 62/264 table 34. p4sfs0: port 4 special function sele ct 0 register (sfr 92h, reset value 00h) table 35. p4sfs1: port 4 special function sele ct 1 register (sfr 93h, reset value 00h) table 36. p4sfs0 and p4sfs1 details bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p4sf07 p4sf06 p4sf05 p4sf04 p4sf03 p4sf02 p4sf01 p4sf00 details bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 p4sf17 p4sf16 p4sf15 p4sf14 p4sf13 p4sf12 p4sf11 p4sf10 port 4 pin r/w default port function alternate 1 port function alternate 2 port function p4sfs0[i] = 0 p4sfs1[i] = x p4sfs0[i] = 1 p4sfs1[i] = 0 p4sfs0[i] = 1 p4sfs1[i] = 1 port 4 pin, i = 0.. 7 port 4 pin, i = 0.. 7 port 4 pin, i = 0.. 7 0 r,w gpio pca0 module 0, tcm0 timer 2 count input, t2 1 r,w gpio pca0 module 1, tcm1 timer 2 trigger input, tx2 2 r,w gpio pca0 module 2, tcm2 uart1 receive, rxd1 3 r,w gpio pca0 ext clock, pcaclk0 uart1 transmit, txd1 4 r,w gpio pca1 module 3, tcm3 spi clock, spiclk 5 r,w gpio pca1 module 4, tcm4 spi receive, spirxd 6 r,w gpio pca1 module 5, tcm5 spi transmit, spitxd 7 r,w gpio pca1 ext clock, pcaclk1 spi select, spisel_
63/264 upsd34xx - mcu bus interface mcu bus interface the mcu module has a programmable bus inter- face which is a modified 8032 bus with 16 multi- plexed address and data lines. the bus supports four types of data transfer (16- or 8-bit), each transfer is to/from a memory location external to the mcu module: ? code fetch cycle using the psen signal: fetch a 16-bit code word fo r filling the pre-fetch queue. the cpu fetches a code byte from the pfq for execution; ? code read cycle using psen: read a 16-bit code word using the movc (move constant) instruction. the code word is routed directly to the cpu and by-pass the pfq; ? xdata read cycle using the rd signal: read a data byte using the movx (move external) instruction; and ? xdata write cycle using the wr signal: write a data byte using the movx instruction psen bus cycles in a psen bus cycle, the mcu module fetches the instruction from the 16-bit program memory in the psd module. the multiplexed address/data bus ad[15:0] is connected to the psd module for 16- bit data transfer. the upsd34xx does not support external psen cycles and cannot fetch instruction from other external pr ogram memory devices. read or write bus cycles in an xdata read or write bus cycle, the mcu?s multiplexed ad[15:0] bus is connected to the psd module, but only the lower bytes ad[7:0] are used for the 8-bit data transfer. the ad[7:0] lines are also connected to pins in the 80-pin pack- age for accessing external devices. if the high ad- dress byte a[15:8] is needed for external devices, port b in the psd module can be configured to provide the latched a[15:8] address outputs. connecting external devices to the mcu bus the upsd34xx supports 8-bit only external i/o or data memory devices. the read and write data transfer is carried out on the ad[7:0] bus which is available in the 80-pin package. the ad- dress lines can be brought out to the external de- vices in one of three ways: 1. configure ports b and a of the psd module in address output mode, as shown in figure 20 ; 2. use port b together with an external latch, as shown in figure 21., page 64 . the external latch latches the low address byte from the ad[7:0] bus with the ale signal.this configuration is for design where port a is needed for cpld functions; and 3. configure the microcell in the cpld to output any address line to any of the cpld output pins. this is the most flexible implementation but requires the use of cpld resources. ports a and b in the psd module can be config- ured in the psdsoft to provide latched mcu ad- dress a[7:0] and a[15:8] (see psd module detailed operation, page 178 for details on how to enable address output mode). the latched ad- dress outputs on the ports are pin configurable. for example, port b pins pb[2:0] can be enabled to provide a[10:8] and the remaining pins can be configured for other functions such as generating chip selects to the external devices. figure 20. connecting external devices using ports a and b for address ad[15:0] upsd34xx psd module external 8-bit device mcu module ai10434 ad[7:0] d[7:0] a8-15 a0-7 port a cs port b ad[15:8] psen ale rd or wr rd or wr
upsd34xx - mcu bus interface 64/264 figure 21. connecting external devices using port a and an external latch for address ad[15:0] programmable bus timing the length of the bus cycles are user programma- ble at run time. the number of mcu_clk periods in a bus cycle can be specified in the sfr register named buscon (see table 37., page 65 ). by de- fault, the buscon register is loaded with long bus cycle times (6 mcu_clk periods) after a re- set condition. it is important that the post-reset ini- tialization firmware sets the bus cycle times appropriately to get the most performance, ac- cording to table 38., page 66 . keep in mind that the psd module has a faster turbo mode (default) and a slower but less power consuming non-tur- bo mode. the bus cycle times must be pro- grammed in buscon to optimize for each mode as shown in table 38. see psd module detailed operation, page 178 for more details. it is not possible to specify in the buscon regis- ter a different number of mcu_clk periods for various address ranges. for example, the user cannot specify 4 mcu_clk periods for rd read cycles to one address range on the psd module, and 5 mcu_clk periods for rd read cycles to a different address range on an external device. however, the user can specify one number of clock periods for psen read cycles and a different number of clock periods for rd or wr cycles (see figure figure 22., page 65 ). controlling the pfq and bc the buscon register allows firmware to enable and disable the pfq and bc at run-time. some- times it may be desired to disable the pfq and bc to ensure deterministic execution. the dynamic action of the pfq and bc may cause varying pro- gram execution times depending on the events that happen prior to a particular section of code of interest. for this reason, it is not recommended to implement timing loops in firmware, but instead use one of the many hardware timers in the upsd34xx. by default, the pfq and bc are en- abled after a reset condition. important: disabling the pfq or bc will seriously reduce mcu performance. upsd34xx psd module external 8-bit device l a t c h mcu module ai10435 ad[7:0] d[7:0] a7-0 a8-15 cs port b ad[15:8] psen ale rd or wr rd or wr
65/264 upsd34xx - mcu bus interface figure 22. a rd or psen bus cycle set to 5 mcu_clk note: 1. the psen cycle is 16-bit, while the rd cycle is 8-bit only. 2. a psen bus cycle in progress may be aborted before completion if the pfq and branch cache (bc) determines the current code fetch cycle is not needed. 3. whenever the same number of mcu_clk periods is specified in buscon for both psen and rd cycles, the bus cycle timing is typically identical for each of these types of bus cycles. in this case, the only time psen read cycles are longer than rd read cycles is when the pfq issues a stall while reloading. pfq stalls do not affect rd read cycles. by comparison, in many traditional 805 1 architectures, rd bus cycles are always longer than psen bus cycles. table 37. buscon: bus control register (sfr 9dh, reset value ebh) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 epfq ebc wrw[1:0] rdw[1:0] cw[1:0] details bit symbol r/w definition 7 epfq r,w enable pre-fetch queue 0 = pfq is disabled 1 = pfq is enabled (default) 6 ebc r,w enable branch cache 0 = bc is disabled 1 = bc is enabled (default) 5:4 wrw[1:0] r,w wr wait, number of mcu_clk periods for wr write bus cycle during any movx instruction 00b: 4 clock periods 01b: 5 clock periods 10b: 6 clock periods (default) 11b: 7 clock periods 3:2 rdw[1:0] r,w rd wait, number of mcu_clk periods for rd read bus cycle during any movx instruction 00b: 4 clock periods 01b: 5 clock periods 10b: 6 clock periods (default) 11b: 7 clock periods 1:0 cw[1:0] r,w code wait, number of mcu_clk periods for psen read bus cycle during any code byte fetch or during any movc code byte read instruction. periods will increase with pfq stall 00b: 3 clock periods - exception, fo r movc instructions this setting results 4 clock periods 01b: 4 clock periods 10b: 5 clock periods 11b: 6 clock periods (default) a0-a15 mcu clock ale ad0-ad15 1 2 3 4 5 d0-d15 (1) 5-clock bus cycle rd/psen (2,3) ai10436
upsd34xx - mcu bus interface 66/264 table 38. number of mcu_clk periods required to optimize bus transfer rate note: 1. v dd of the psd module 2. ?turbo mode psd? means that the psd module is in the faster, turbo mode (default condition). a psd module in non-turbo mode is slower, but consumes less current. see psd module section, titled ?pld non-turbo mode? for details. mcu clock frequency, mcu_clk (f mcu ) cw[1:0] clk periods rdw[1:0] clk periods wrw[1:0] clk periods 3.3v (1) 5v (1) 3.3v (1) 5v (1) 3.3v (1) 5v (1) 40mhz, turbo mode psd (2) 545454 40mhz, non-turbo mode psd 656565 36mhz, turbo mode psd 545454 36mhz, non-turbo mode psd 646464 32mhz, turbo mode psd 545454 32mhz, non-turbo mode psd 545454 28mhz, turbo mode psd 434444 28mhz, non-turbo mode psd 545454 24mhz, turbo mode psd 434444 24mhz, non-turbo mode psd 434444 20mhz and below, turbo mode psd 334444 20mhz and below, non-turbo mode psd 334444
67/264 upsd34xx - supervisory functions supervisory functions supervisory circuitry on the mcu module will issue an internal reset signal to the mcu module and si- multaneously to the psd module as a result of any of the following four events: ? the external reset_in pin is asserted ? the low voltage detect (lvd) circuitry has detected a voltage on v cc below a specific threshold (power-on or voltage sags) ? the jtag debug interface has issued a reset command ? the watch dog timer (wdt) has timed out the resulting internal reset signal, mcu_reset, will force the 8032 into a known reset state while asserted, and then 8032 program execution will jump to the reset vector at program address 0000h just after mcu_reset is deasserted. the mcu module will also assert an ac tive low internal reset signal, reset , to the psd module. if needed, the signal reset can be driven out to external sys- tem components through any pld output pin on the psd module. when driving this ?reset_out? signal from a pld output, the user can choose to make it either active-high or active- low logic, depending on the pld equation. external reset i nput pin, reset_in the reset_in pin can be connected directly to a mechanical reset switch or other device which pulls the signal to ground to invoke a reset. reset_in is pulled up internally and enters a schmitt trigger input buffer with a voltage hystere- sis of v rst_hys for immunity to the effects of slow signal rise and fall times, as shown in figure 23 . reset_in is also filtered to reject a voltage spike less than a duration of t rst_fil . the reset_in signal must be maintained at a logic '0' for at least a duration of t rst_lo_in while the oscillator is run- ning. the resulting mcu_reset signal will last only as long as the reset_in signal is active (it is not stretched). refer to the supervisor ac specifi- cations in table 178., page 253 at the end of this document for these parameter values. figure 23. supervisor reset generation q s mcu clock sync noise filter v cc pin pull-up delay, t rst_actv r ai09603 reset_in reset to psd module mcu_reset to mcu and peripherals lv d jtag debug wdt
upsd34xx - supervisory functions 68/264 low v cc voltage detect, lvd an internal reset is generated by the lvd circuit when v cc drops below the reset threshold, v lv_thresh . after v cc returns to the reset thresh- old, the mcu_reset si gnal will remain asserted for t rst_actv before it is released. the lvd circuit is always enabled (cannot be disabled by sfr), even in idle mode and power-down mode. the lvd input has a voltage hysteresis of v rst_hys and will reject voltage spik es less than a duration of t rst_fil . important: the lvd voltage threshold is v lv_thresh , suitable for monitoring both the 3.3v v cc supply on the mcu module and the 3.3v v dd supply on the psd module for 3.3v upsd34xxv devices, since these supplies are one in the same on the circuit board. however, for 5v u psd34xx devices, v lv_thresh is not suitable for monitoring the 5v v dd voltage supply (v lv_thresh is too low), but good for mon- itoring the 3.3v v cc supply. in the case of 5v upsd34xx devices, an external means is required to monitor the separate 5v v dd supply, if desired. power-up reset at power up, the internal reset generated by the lvd circuit is latched as a logic '1' in the por bit of the sfr named pcon ( table 26., page 52 ). software can read this bit to determine whether the last mcu reset was the result of a power up (cold reset) or a reset from some other condition (warm reset). this bit must be cleared with soft- ware. jtag debug reset the jtag debug unit can generate a reset for de- bugging purposes. this reset source is also avail- able when the mcu is in idle mode and power- down mode (the user can use the jtag debugger to exit these modes). watchdog timer, wdt when enabled, the wd t will generate a reset whenever it overflows. firmware that is behaving correctly will periodically clear the wdt before it overflows. run-away firm ware will not be able to clear the wdt, and a reset will be generated. by default, the wdt is disabled after each reset. note: the wdt is not active during idle mode or power-down mode. there are two sfrs that control the wdt, they are wdkey ( table 39., page 70 ) and wdrst ( table 40., page 70 ). if wdkey contains 55h, the wdt is disabled. any value other than 55h in wdkey will enable the wdt. by default, after any reset condition, wd- key is automatically loa ded with 55h, disabling the wdt. it is the respon sibility of initialization firmware to write some value other than 55h to wdkey after each reset if the wdt is to be used. the wdt consists of a 24-bit up-counter (figure 24 ), whose initial count is 000000h by default after every reset. the most significant byte of this counter is controlled by the sfr, wdrst. after being enabled by wdkey, the 24-bit count is in- creased by 1 for each mcu machine cycle. when the count overflows beyond fffffh (2 24 mcu machine cycles), a reset is issued and the wdt is automatically disabled (wdkey = 55h again). to prevent the wdt from timing out and generat- ing a reset, firmware must repeatedly write some value to wdrst before the count reaches fffffh. whenever wdrst is written, the upper 8 bits of the 24-bit counter are loaded with the writ- ten value, and the lower 16 bits of the counter are cleared to 0000h. the wdt time-out period can be adjusted by writ- ing a value other that 00h to wdrst. for exam- ple, if wdrst is written with 04h, then the wdt will start counting 0400 00h, 040001h, 040002h, and so on for each mcu machine cycle. in this ex- ample, the wdt time-out period is shorter than if wdrst was written with 00h, because the wdt is an up-counter. a value for wdrst should never be written that results in a wdt time-out period shorter than the time required to complete the longest code task in the application, else unwant- ed wdt overflows will occur. figure 24. watchdog counter 23 15 7 0 8-bits 8-bits 8-bits sfr, wdrst ai09604
69/264 upsd34xx - supervisory functions the formula to determine wdt time-out period is: wdt period = t mach_cyc x n overflow n overflow is the number of wdt up-counts re- quired to reach ffffffh. this is determined by the value written to the sfr, wdrst. t mach_cyc is the average duration of one mcu machine cycle. by default, an mcu machine cycle is always 4 mcu_clk periods for upsd34xx, but the following factors can sometimes add more mcu_clk periods per machine cycle: ? the number of mcu_clk periods assigned to mcu memory bus cycles as determined in the sfr, buscon. if this setting is greater than 4, then machine cycles have additional mcu_clk periods during memory transfers. ? whether or not the pfq/bc circuitry issues a stall during a particular mcu machine cycle. a stall adds more mcu_clk periods to a machine cycle until the stall is removed. t mach_cyc is also affected by the absolute time of a single mcu_clk period. this number is fixed by the following factors: ? frequency of the external crystal, resonator, or oscillator: (f osc ) ? bit settings in the sfr ccon0, which can divide f osc and change mcu_clk as an example, assume the following: 1. f osc is 40mhz, thus its period is 25ns. 2. ccon0 is 10h, meaning no clock division, so the period of mcu_clk is also 25ns. 3. buscon is c1h, meaning the pfq and bc are enabled, and each mcu memory bus cycle is 4 mcu_clk periods, adding no additional mcu_clk periods to mcu machine cycles during memory transfers. 4. assume there are no stalls from the pfq/bc. in reality, there are occational stalls but their occurance has minimal impact on wdt timeout period. 5. wdrst contains 00h, meaning a full 2 24 up- counts are required to reach fffffh and generate a reset. in this example, t mach_cyc = 100ns (4 mcu_clk periods x 25ns) n overflow = 2 24 = 16777216 up-counts wdt period = 100ns x 16777216 = 1.67 seconds the actual value will be sli ghtly longer due to pfq/ bc. firmware example: the following 8051 assem- bly code illustrates how to operate the wdt. a simple statement in the re set initialization firmware enables the wdt, and then a periodic write to clear the wdt in the main firmware is required to keep the wdt from overflowing. this firmware is based on the example above (40mhz f osc , ccon0 = 10h, buscon = c1h). for example, in the rese t initialization firmware (the function that executes after a jump to the reset vector): somewhere in the flow of the main program, this statement will execute periodically to reset the wdt before its time-out period of 1.67 seconds. for example: mov ae, #aa ; enable wdt by writing value to ; wdkey other than 55h mov a6, #00 ; reset wdt, loading 000000h. ; counting will automatically ; resume as long as 55h in not in ; wdkey
upsd34xx - supervisory functions 70/264 table 39. wdkey: watchdog timer key register (sfr aeh, reset value 55h) table 40. wdrst: watchdog timer reset counter register (sfr a6h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 wdkey[7:0] details bit symbol r/w definition [7:0] wdkey w 55h disables the wdt from counting. 55h is automatically loaded in this sfr after any reset condition, le aving the wdt disabled by default. any value other than 55h written to this sfr will enable the wdt, and counting begins. bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 wdrst[7:0] details bit symbol r/w definition [7:0] wdrst w this sfr is the upper byte of the 24-bit wdt up-counter. writing this sfr sets the upper byte of the count er to the written value, and clears the lower two bytes of the counter to 0000h. counting begins when wd key does not contain 55h.
71/264 upsd34xx - standard 8032 timer/counters standard 8032 timer/counters there are three 8032-style 16-bit timer/counter registers (timer 0, timer 1, timer 2) that can be configured to operate as timers or event counters. there are two additional 16-bit timer/counters in the programmable counter array (pca), see pca block, page 154 for details. standard timer sfrs timer 0 and timer 1 have very similar functions, and they share two sfrs for control: tcon ( table 41., page 72 ) tmod ( table 42., page 74 ). timer 0 has two sfrs that form the 16-bit counter, or that can hold reload values, or that can scale the clock depending on the timer/counter mode: th0 is the high byte, address 8ch tl0 is the low byte, address 8ah timer 1 has two similar sfrs: th1 is the high byte, address 8dh tl1 is the low byte, address 8bh timer 2 has one control sfr: t2con ( table 43., page 77 ) timer 2 has two sfrs that form the 16-bit counter, and perform other functions: th2 is the high byte, address cdh tl2 is the low byte, address cch timer 2 has two sfrs for capture and reload: rcap2h is the high byte, address cbh rcap2l is the low byte, address cah clock sources when enabled in the ? timer ? function, the regis- ters thx and tlx are incremented every 1/12 of the oscillator frequency (f osc ). this timer clock source is not effected by mcu clock dividers in the ccon0, stalls from pfq/bc, or bus transfer cy- cles. timers are always clocked at 1/12 of f osc . when enabled in the ? counter ? function, the reg- isters thx and tlx are incremented in response to a 1-to-0 transition sampled at their corresponding external input pin: pin c0 for timer 0; pin c1 for timer 1; or pin t2 for timer 2. in this function, the external clock input pin is sampled by the counter at a rate of 1/12 of f osc . when a logic '1' is deter- mined in one sample, and a logic '0' in the next sample period, the count is incremented at the very next sample period (period1: sample=1, period2: sample=0, period3: increment count while continuing to samp le). this means the max- imum count rate is 1/24 of the f osc . there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be active for at least one full sample period (12 / f osc, sec- onds). however, if mcu_clk is divided by the sfr ccon0, then the sample period must be cal- culated based on the resultant, longer, mcu_clk frequency. in this case, an external clock signal on pins c0, c1, or t2 should have a duration longer than one mcu machine cycle, t mach_cyc . the section, watchdog timer, wdt, page 68 explains how to estimate t mach_cyc .
upsd34xx - standard 8032 timer/counters 72/264 table 41. tcon: timer control register (sfr 88h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 details bit symbol r/w definition 7 tf1 r timer 1 overflow interrupt flag. set by hardware upon overflow. automatically cleared by hardware afte r firmware services the interrupt for timer 1. 6 tr1 r,w timer 1 run control. 1 = timer/count er 1 is on, 0 = timer/counter 1 is off. 5 tf0 r timer 0 overflow interrupt flag. set by hardware upon overflow. automatically cleared by hardware afte r firmware services the interrupt for timer 0. 4 tr0 r,w timer 0 run control. 1 = timer/count er 0 is on, 0 = timer/counter 0 is off. 3ie1r interrupt flag for external interrupt pin, extint1. set by hardware when edge is detected on pin. automati cally cleared by hardware after firmware services extint1 interrupt. 2it1r,w trigger type for external interrupt pi n extint1. 1 = falling edge, 0 = low- level 1ie0r interrupt flag for external interrupt pin, extint0. set by hardware when edge is detected on pin. automati cally cleared by hardware after firmware services extint0 interrupt. 0it0r,w trigger type for external interrupt pi n extint0. 1 = falling edge, 0 = low- level
73/264 upsd34xx - standard 8032 timer/counters sfr, tcon timer 0 and timer 1 share the sfr, tcon, that controls these timers and provides information about them. see table 41., page 72 . bits ie0 and ie1 are not related to timer/counter functions, but they are set by hardware when a signal is active on one of the two external interrupt pins, extint0 and extint1. for system informa- tion on all of these interrupts, see table 16., page 42 , interrupt summary. bits it0 and it1 are not related to timer/counter functions, but they control whether or not the two external interrupt input pins, extint0 and extint1 are edge or level triggered. sfr, tmod timer 0 and timer 1 have four modes of operation controlled by the sfr named tmod (table 42 ). timer 0 and timer 1 operating modes the ?timer? or ?counter? function is selected by the c/t control bits in tmod. the four operating modes are selected by bit-pairs m[1:0] in tmod. modes 0, 1, and 2 are the same for both timer/ counters. mode 3 is different. mode 0. putting either timer/counter into mode 0 makes it an 8-bit counter with a divide-by-32 pre- scaler. figure 25 shows mode 0 operation as it ap- plies to timer 1 (same applies to timer 0). in this mode, the timer register is configured as a 13-bit register. as the count rolls over from all '1s' to all '0s,' it sets the timer interrupt flag tf1. the counted input is enabled to the timer when tr1 = 1 and either gate = 0 or extint1 = 1. (setting gate = 1 allows the timer to be con- trolled by external input pin, extin t1, to facilitate pulse width measurements). tr1 is a control bit in the sfr, tcon. gate is a bit in the sfr, tmod. the 13-bit register consists of all 8 bits of th1 and the lower 5 bits of tl1. the upper 3 bits of tl1 are indeterminate and should be ignored. setting the run flag, tr1, does not clear the registers. mode 0 operation is the same for the timer 0 as for timer 1. substitute tr0, tf0, c0, tl0, th0, and extint0 for the corresponding timer 1 sig- nals in figure 25 . there are two different gate bits, one for timer 1 and one for timer 0. mode 1. mode 1 is the same as mode 0, except that the timer register is being run with all 16 bits. mode 2. mode 2 configures the timer register as an 8-bit counter (tl1) with automatic reload, as shown in figure 26., page 75 . overflow from tl1 not only sets tf1, but also reloads tl1 with the contents of th1, which is preset with firmware. the reload leaves th1 unchanged. mode 2 oper- ation is the same for timer/counter 0. mode 3. timer 1 in mode 3 simply holds its count. the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate counters. the logic for mode 3 on timer 0 is shown in figure 27., page 75 . tl0 uses the timer 0 control bits: c/t , gate, tr0, and tf0, as well as the pin extint0. th0 is locked into a timer function (counting at a rate of 1/12 f osc ) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the ?timer 1? interrupt flag. mode 3 is provided for applications requiring an extra 8-bit timer on the counter (see figure 27., page 75 ). with timer 0 in mode 3, a upsd34xx device can look like it has three timer/ counters (not including the pca). when timer 0 is in mode 3, timer 1 can be turned on and off by switching it out of and into its own mode 3, or can still be used by the serial port as a baud rate gen- erator, or in fact, in any application not requiring an interrupt.
upsd34xx - standard 8032 timer/counters 74/264 table 42. tmod: timer mode register (sfr 89h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 gate c/t m[1:0] gate c/t m[1:0] details bit symbol r/w timer definition (t/c is abbreviation for timer/counter) 7gater,w timer 1 gate control. when gate = 1, t/c is enabled only while pin extint1 is '1' and the flag tr1 is '1.' when gate = 0, t/c is enabled whenever the flag tr1 is '1.' 6c/t r,w counter or timer function select. when c/t = 0, function is timer, clocked by internal clock. c/t = 1, function is counter, clocked by signal sampled on external pin, c1. [5:4] m[1:0] r,w mode select. 00b = 13-bit t/c. 8 bits in th1 with tl1 as 5-bit pre- scaler. 01b = 16-bit t/c. th1 and tl1 are cascaded. no pre- scaler. 10b = 8-bit auto-reload t/c. th1 holds a constant and loads into tl1 upon overflow. 11b = timer counter 1 is stopped. 3gater,w timer 0 gate control. when gate = 1, t/c is enabled only while pin extint0 is '1' and the flag tr0 is '1.' when gate = 0, t/c is enabled whenever the flag tr0 is '1.' 2c/t r,w counter or timer function select. when c/t = 0, function is timer, clocked by internal clock. c/t = 1, function is counter, clocked by signal sampled on external pin, c0. [1:0] m[1:0] r,w mode select. 00b = 13-bit t/c. 8 bits in th0 with tl0 as 5-bit pre- scaler. 01b = 16-bit t/c. th0 and tl0 are cascaded. no pre- scaler. 10b = 8-bit auto-reload t/c. th0 holds a constant and loads into tl0 upon overflow. 11b = tl0 is 8-bit t/c controlled by standard timer 0 control bits. th0 is a separate 8-bit timer that uses timer 1 control bits.
75/264 upsd34xx - standard 8032 timer/counters figure 25. timer/counter mode 0: 13-bit counter figure 26. timer/counter mode 2: 8-bit auto-reload figure 27. timer/counter mode 3: two 8-bit counters ai06622 f osc tf1 interrupt gate tr1 extint1 pin c1 pin control tl1 (5 bits) th1 (8 bits) c/t = 0 c/t = 1 12 ai06623 f osc tf1 interrupt gate tr1 extint1 pin c1 pin control tl1 (8 bits) th1 (8 bits) c/t = 0 c/t = 1 12 ai06624 f osc tf0 interrupt gate tr0 extint0 pin c0 pin control tl0 (8 bits) c/t = 0 c/t = 1 12 f osc tf1 interrupt control th0 (8 bits) 12 tr1
upsd34xx - standard 8032 timer/counters 76/264 timer 2 timer 2 can operate as either an event timer or as an event counter. this is selected by the bit c/t2 in the sfr named, t2con ( table 43., page 77 ). timer 2 has three operating modes selected by bits in t2con, according to table 44., page 78 . the three modes are: capture mode auto re-load mode baud rate generator mode capture mode. in capture mode there are two options which are selected by the bit exen2 in t2con. figure 28., page 81 illustrates capture mode. if exen2 = 0, then timer 2 is a 16-bit timer if c/t2 = 0, or it is a 16-bit counter if c/t2 = 1, either of which sets the interrupt flag bit tf2 upon overflow. if exen2 = 1, then time r 2 still does the above, but with the added feature that a 1-to-0 transition at external input pin t2x causes the current value in the timer 2 registers, tl2 and th2, to be cap- tured into registers rcap2l and rcap2h, re- spectively. in addition, the transition at t2x causes interrupt flag bit exf2 in t2con to be set. either flag tf2 or exf2 will generate an interrupt and the mcu must read both flags to determine the cause. flags tf2 and exf2 are not automati- cally cleared by hardware, so the firmware servic- ing the interrupt must clear the flag(s) upon exit of the interrupt service routine. auto-reload mode. in the auto-reload mode, there are again two options, which are selected by the bit exen2 in t2con. figure 29., page 81 shows auto-reload mode. if exen2 = 0, then when timer 2 counts up and rolls over from ffffh it not only sets the interrupt flag tf2, but also causes the timer 2 registers to be reloaded with the 16-bit value contained in registers rcap2l and rcap2h, which are pre- set with firmware. if exen2 = 1, then time r 2 still does the above, but with the added feature that a 1-to-0 transition at external input t2x will al so trigger the 16-bit re- load and set the interrupt flag exf2. again, firm- ware servicing the interrupt must read both tf2 and exf2 to determine the cause, and clear the flag(s) upon exit. note: the upsd34xx does not support selectable up/down counting in auto-reload mode (this fea- ture was an extension to the original 8032 archi- tecture).
77/264 upsd34xx - standard 8032 timer/counters table 43. t2con: timer 2 control re gister (sfr c8h, reset value 00h) note: 1. the rclk1 and tclk1 bits in the sfr named pcon control uart1, and have the exact same function as rclk and tclk. bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl 2 details bit symbol r/w definition 7 tf2 r,w timer 2 flag, causes interrupt if enabled. tf2 is set by hardware upon overflow. must be cleared by firmware. tf2 will not be set when eit her rclk or tclk =1. 6 exf2 r,w timer 2 flag, causes interrupt if enabled. exf2 is set when a capture or reload is caused by a negative transition on t2x pin and exen2 = 1. exf2 must be cleared by firmware. 5 rclk (1) r,w uart0 receive clock control. when rclk = 1, uart0 uses timer 2 overflow pulses for its receive clock in modes 1 and 3. rclk=0, timer 1 overflow is used for its receive clock 4 tclk (1) r,w uart0 transmit clock control. when tclk = 1, uart0 uses timer 2 overflow pulses for its transmit clock in modes 1 and 3. tclk=0, timer 1 overflow is used for transmit clock 3 exen2 r,w timer 2 external enable. when exen2 = 1, capture or reload results when negative edge on pin t2x occurs. exen2 = 0 causes timer 2 to ignore events at pin t2x. 2 tr2 r,w timer 2 run control. 1 = timer/counter 2 is on, 0 = timer counter 2 is off. 1c/t2 r,w counter or timer function select. when c/t2 = 0, function is timer, clock ed by internal clock. when c/t2 = 1, function is counter, clocked by signal sampled on external pin, t2. 0cp/rl2 r,w capture/reload. when cp/rl2 = 1, capture occurs on negative transition at pin t2x if exen2 = 1. when cp/rl2 = 0, auto-reload occurs when timer 2 overflows, or on negativ e transition at pin t2x when exen2=1. when rclk = 1 or tclk = 1, cp/rl2 is ignored, and timer 2 is forced to auto- reload upon timer 2 overflow
upsd34xx - standard 8032 timer/counters 78/264 table 44. timer/counter 2 operating modes note: = falling edge mode bits in t2con sfr pin t2x remarks input clock rclk or tclk cp/ rl2 tr2 exen2 timer, internal counter, external (pin t2, p1.0) 16-bit auto- reload 001 0 x reload [rcap2h, rcap2l] to [th2, tl2] upon overflow (up counting) f osc /12 max f osc /24 001 1 reload [rcap2h, rcap2l] to [th2, tl2] at falling edge on pin t2x 16-bit capture 0 1 1 0 x 16-bit timer/c ounter (up counting) f osc /12 max f osc /24 011 1 capture [th2, tl2] and store to [rcap2h, rcap2l] at falling edge on pin t2x baud rate generator 1 x 1 0 x no overflow interrupt request (tf2) f osc /2 ? 1x1 1 extra interrupt on pin t2x, sets tf2 off x x 0 x x timer 2 stops ? ?
79/264 upsd34xx - standard 8032 timer/counters baud rate generator mode. the rclk and/or tclk bits in the sfr t2con allow the transmit and receive baud rates on serial port uart0 to be derived from either timer 1 or timer 2. figure 30., page 82 illustrates baud rate generator mode. when tclk = 0, timer 1 is used as uart0?s transmit baud generator. when tclk = 1, timer 2 will be the transmit baud generator. rclk has the same effect for uart0?s receive baud rate. with these two bits, uart0 c an have different receive and transmit baud rates - one generated by timer 1, the other by timer 2. note: bits rclk1 and tclk1 in the sfr named pcon (see pcon: power control register (sfr 87h, reset value 00h), page 52 ) have identical functions as rclk and tclk but they apply to uart1 instead. for simplic ity in the following dis- cussions about baud rate generation, no suffix will be used when referring to sfr registers and bits related to uart0 or uart1, since each uart in- terface has identical operation. example, tclk or tclk1 will be referred to as just tclk. the baud rate generator mode is similar to the auto-reload mode, in that a roll over in th2 causes the timer 2 registers, th2 and tl2, to be reloaded with the 16-bit value in registers rcap2h and rcap2l, which are preset with firmware. the baud rates in uart modes 1 and 3 are deter- mined by timer 2?s overflow rate as follows: uart mode 1,3 baud rate = timer 2 overflow rate / 16 the timer can be configured for either ?timer? or ?counter? operation. in the most typical applica- tions, it is configured for ?timer? operation (c/t2 = 0). ?timer? operation is a little different for timer 2 when it's being used as a baud rate generator. in this case, the baud rate is given by the formula: uart mode 1,3 baud rate = f osc /(32 x [65536 ? [rcap2h, rcap2l])) where [rcap2h, rcap2l] is the content of the sfrs rcap2h and rcap2l taken as a 16-bit un- signed integer. a roll-over in th2 does not set tf2, and will not generate an interrupt. therefore, the timer inter- rupt does not have to be disabled when timer 2 is in the baud rate generator mode. if exen2 is set, a 1-to-0 transition on pin t2x will set the timer 2 interrupt flag exf2, but will not cause a reload from rcap2h and rcap2l to th2 and tl2. thus when timer 2 is in use as a baud rate generator, the pin t2x can be used as an extra external interrupt, if desired. when timer 2 is running (tr2 = 1) in a ?timer? function in the baud rate generator mode, firm- ware should not read or write th2 or tl2. under these conditions the results of a read or write may not be accurate. however, sfrs rcap2h and rcap2l may be read, but should not be written, because a write might overlap a reload and cause write and/or reload errors. timer 2 should be turned off (clear tr2) before accessing timer 2 or registers rcap2h and rcap2l, in this case. table 45., page 80 shows commonly used baud rates and how they can be obtained from timer 2, with t2con = 34h.
upsd34xx - standard 8032 timer/counters 80/264 table 45. commonly used baud rates generated from timer2 (t2con = 34h) f osc mhz desired baud rate timer 2 sfrs resulting baud rate baud rate deviation rcap2h (hex) rcap2l(hex) 40.0 115200 ff f5 113636 -1.36% 40.0 57600 ff ea 56818 -1.36% 40.0 28800 ff d5 29070 0.94% 40.0 19200 ff bf 19231 0.16% 40.0 9600 ff 7e 9615 0.16% 36.864 115200 ff f6 115200 0 36.864 57600 ff ec 57600 0 36.864 28800 ff d8 28800 0 36.864 19200 ff c4 19200 0 36.864 9600 ff 88 9600 0 36.0 28800 ff d9 28846 0.16% 36.0 19200 ff c5 19067 -0.69% 36.0 9600 ff 8b 9615 0.16% 24.0 57600 ff f3 57692 0.16% 24.0 28800 ff e6 28846 0.16% 24.0 19200 ff d9 19231 0.16% 24.0 9600 ff b2 9615 0.16% 12.0 28800 ff f3 28846 0.16% 12.0 9600 ff d9 9615 0.16% 11.0592 115200 ff fd 115200 0 11.0592 57600 ff fa 57600 0 11.0592 28800 ff f4 28800 0 11.0592 19200 ff ee 19200 0 11.0592 9600 ff dc 9600 0 3.6864 115200 ff ff 115200 0 3.6864 57600 ff fe 57600 0 3.6864 28800 ff fc 28800 0 3.6864 19200 ff fa 19200 0 3.6864 9600 ff f4 9600 0 1.8432 19200 ff fd 19200 0 1.8432 9600 ff fa 9600 0
81/264 upsd34xx - standard 8032 timer/counters figure 28. timer 2 in capture mode figure 29. timer 2 in auto-reload mode ai06625 f osc tf2 capture tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt transition detector ai06626 f osc tf2 reload tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt transition detector
upsd34xx - standard 8032 timer/counters 82/264 figure 30. timer 2 in baud rate generator mode ai09605 f osc reload tr2 t2 pin control note: oscillator frequency is divided by 2, not 12 like in other timer modes. note: availability of additional external interrupt. tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 2 16 16 exf2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt tx clk rx clk timer 1 overflow smod rclk '1' '0' '1' '0' '1' '0' tclk transition detector
83/264 upsd34xx - serial uart interfaces serial uart interfaces upsd34xx devices provide two standard 8032 uart serial ports. ? the first port, uart0, is connected to pins rxd0 (p3.0) and txd0 (p3.1) ? the second port, uart1 is connected to pins rxd1 (p1.2) and txd1 (p1.3). uart1 can optionally be routed to pins p4.2 and p4.3 as described in alternate functions, page 60 . the operation of the two serial ports are the same and are controlled by two sfrs: scon0 ( table 47., page 84 ) for uart0 scon1 ( table 48., page 85 ) for uart1 each uart has its own data buffer accessed through an sfr listed below: sbuf0 for uart0, address 99h sbuf1 for uart1, address d9h when writing sbu0 or sbuf1, the data automati- cally loads into the associated uart transmit data register. when reading this sfr, data comes from a different physical register, which is the receive register of the associated uart. note: for simplicity in the remaining uart dis- cussions, the suffix ?0? or ?1? will be dropped when referring to sfr registers and bits related to uart0 or uart1, since ea ch uart interface has identical operation. example, sbuf0 and sbuf1 will be referred to as just sbuf. each uart serial port can be full-duplex, meaning it can transmit and receive simultaneously. each uart is also receive-buffered, meaning it can commence reception of a second byte before a previously received byte has been read from the sbuf register. however, if the first byte still has not been read by the time reception of the second byte is complete, one of the bytes will be lost. uart operation modes each uart can operate in one of four modes, one mode is synchronous, and the others are asyn- chronous as shown in table 46 . mode 0. mode 0 provides asynchronous, half-du- plex operation. serial data is both transmitted, and received on the rxd pin. the txd pin outputs a shift clock for both transmit and receive directions, thus the mcu must be the master. eight bits are transmitted/received lsb first. the baud rate is fixed at 1/12 of f osc . mode 1. mode 1 provides standard asynchro- nous, full-duplex communication using a total of 10 bits per data byte. data is transmitted through txd and received through rxd with: a start bit (logic '0'), eight data bits (lsb first), and a stop bit (logic '1'). upon receive, the eight data bits go into the sfr sbuf, and the stop bit goes into bit rb8 of the sfr scon. the baud rate is variable and de- rived from overflows of timer 1 or timer 2. mode 2. mode 2 provides asynchronous, full-du- plex communication using a total of 11 bits per data byte. data is transmitted through txd and re- ceived through rxd with: a start bit (logic '0'); eight data bits (lsb first); a programmable 9th data bit; and a stop bit (logic '1'). upon transmit, the 9th data bit (from bit tb8 in scon) can be as- signed the value of '0' or '1.' or, for example, the parity bit (p, in the psw) could be moved into tb8. upon receive, the 9th data bit goes into rb8 in scon, while the stop bit is ignored. the baud rate is programmable to either 1/32 or 1/64 of f osc . mode 3. mode 3 is the same as mode 2 in all re- spects except the baud rate is variable like it is in mode 1. in all four modes, transmi ssion is initiated by any instruction that uses sbuf as a destination regis- ter. reception is initiated in mode 0 by the condi- tion ri = 0 and ren = 1. reception is initiated in the other modes by the incoming start bit if ren = 1. table 46. uart operating modes mode synchronization bits of sfr, scon baud clock data bits start/stop bits see figure sm0 sm1 0 synchronous 0 0 f osc /12 8 none figure 31., page 88 1 asynchronous 0 1 timer 1 or timer 2 overflow 8 1 start, 1 stop figure 33., page 90 2 asynchronous 1 0 f osc /32 or f osc /64 9 1 start, 1 stop figure 35., page 92 3 asynchronous 1 1 timer 1 or timer 2 overflow 9 1 start, 1 stop figure 37., page 93
upsd34xx - serial uart interfaces 84/264 multiprocessor communications. modes 2 and 3 have a special provision for multiprocessor com- munications. in these modes, 9 data bits are re- ceived. the 9th one goes into bit rb8, then comes a stop bit. the port can be programmed such that when the stop bit is received, the uart interrupt will be activated only if bit rb8 = 1. this feature is enabled by setting bit sm2 in scon. a way to use this feature in multi-processor systems is as fol- lows: when the master processor wants to trans- mit a block of data to one of several slaves, it first sends out an address byte which identifies the tar- get slave. an address byte differs from a data byte in that the 9th bit is 1 in an address byte and 0 in a data byte. with sm2 = 1, no slave will be interrupt- ed by a data byte. an address byte, however, will interrupt all slaves, so that each slave can exam- ine the received byte and see if it is being ad- dressed. the addr essed slave will clear its sm2 bit and prepare to receive t he data bytes that will be coming. the slaves that were not being addressed leave their sm2 bits set and go on about their busi- ness, ignoring the coming data bytes. sm2 has no effect in mode 0, and in mode 1, sm2 can be used to check the validity of the stop bit. in a mode 1 reception, if sm2 = 1, the receive inter- rupt will not be activate d unless a valid stop bit is received. serial port control registers the sfr scon0 controls uart0, and scon1 controls uart1, shown in table 47 and table 48 . these registers contain not only the mode selec- tion bits, but also the 9th data bit for transmit and receive (bits tb8 and rb8), and the uart inter- rupt flags, ti and ri. table 47. scon0: serial port uart0 control register (sfr 98h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 sm0 sm1 sm2 ren tb8 rb8 ti ri details bit symbol r/w definition 7 sm0 r,w serial mode select, see table 46., page 83 . important, notice bit order of sm0 and sm1. [sm0:sm1] = 00b , mode 0 [sm0:sm1] = 01b , mode 1 [sm0:sm1] = 10b , mode 2 [sm0:sm1] = 11b , mode 3 6sm1r,w 5sm2r,w serial multiprocessor communication enable. mode 0 : sm2 has no effect but should remain 0. mode 1 : if sm2 = 0 then stop bit ignored. sm2 =1 then ri active if stop bit = 1. mode 2 and 3 : multiprocessor comm enable. if sm2=0, 9th bit is ignored. if sm2=1, ri active when 9th bit = 1. 4renr,w receive enable. if ren=0, uart reception disabled. if ren=1, reception is enabled 3tb8r,w tb8 is assigned to the 9th transmission bit in mode 2 and 3. not used in mode 0 and 1. 2rb8r,w mode 0 : rb8 is not used. mode 1 : if sm2 = 0, the rb8 is the level of the received stop bit. mode 2 and 3 : rb8 is the 9th data bit that was received in mode 2 and 3. 1tir,w transmit interrupt flag. causes interrupt at end of 8th bit ti me when transmitting in mode 0, or at beginning of stop bit transmission in ot her modes. must clear flag with firmware. 0rir,w receive interrupt flag. causes interrupt at end of 8th bit time when receiving in mode 0, or halfway through stop bit reception in other modes (see sm2 for exception). must clear this flag with firmware.
85/264 upsd34xx - serial uart interfaces table 48. scon1: serial port uart1 control register (sfr d8h, reset value 00h) bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 sm0 sm1 sm2 ren tb8 rb8 ti ri details bit symbol r/w definition 7 sm0 r,w serial mode select, see table 46., page 83 . important, notice bit order of sm0 and sm1. [sm0:sm1] = 00b , mode 0 [sm0:sm1] = 01b , mode 1 [sm0:sm1] = 10b , mode 2 [sm0:sm1] = 11b , mode 3 6sm1r,w 5sm2r,w serial multiprocessor communication enable. mode 0 : sm2 has no effect but should remain 0. mode 1 : if sm2 = 0 then stop bit ignored. sm2 =1 then ri active if stop bit = 1. mode 2 and 3 : multiprocessor comm enable. if sm2=0, 9th bit is ignored. if sm2=1, ri active when 9th bit = 1. 4renr,w receive enable. if ren=0, uart reception disabled. if ren=1, reception is enabled 3tb8r,w tb8 is assigned to the 9th transmission bit in mode 2 and 3. not used in mode 0 and 1. 2rb8r,w mode 0 : rb8 is not used. mode 1 : if sm2 = 0, the rb8 is the level of the received stop bit. mode 2 and 3 : rb8 is the 9th data bit that was received in mode 2 and 3. 1tir,w transmit interrupt flag. causes interrupt at end of 8th bit ti me when transmitting in mode 0, or at beginning of stop bit transmission in ot her modes. must clear flag with firmware. 0rir,w receive interrupt flag. causes interrupt at end of 8th bit time when receiving in mode 0, or halfway through stop bit reception in other modes (see sm2 for exception). must clear this flag with firmware.
upsd34xx - serial uart interfaces 86/264 uart baud rates the baud rate in mode 0 is fixed: mode 0 baud rate = f osc / 12 the baud rate in mode 2 depends on the value of the bit smod in the sfr named pcon. if smod = 0 (default value), the baud rate is 1/64 the oscil- lator frequency, f osc . if smod = 1, the baud rate is 1/32 the osc illator frequency. mode 2 baud rate = (2 smod / 64) x f osc baud rates in modes 1 and 3 are determined by the timer 1 or timer 2 overflow rate. using timer 1 to ge nerate baud rates. when timer 1 is used as the baud rate generator (bits rclk = 0, tclk = 0), the baud rates in modes 1 and 3 are determined by the timer 1 overflow rate and the value of smod as follows: mode 1,3 baud rate = (2 smod / 32) x (timer 1 overflow rate) the timer 1 interrupt should be disabled in this application. the timer itself can be configured for either ?timer? or ?counter? operation, and in any of its 3 running modes. in the most typical applica- tions, it is configured for ?timer? operation, in the auto-reload mode (high nibble of the sfr tmod = 0010b). in that case the baud rate is given by the formula: mode 1,3 baud rate = (2 smod / 32) x (f osc / (12 x [256 ? (th1)])) table 49 lists various commonly used baud rates and how they can be obtained from timer 1. using timer/counter 2 to generate baud rates. see baud rate generator mode, page 79 . table 49. commonly used baud rates generated from timer 1 uart mode f osc mhz desired baud rate resultant baud rate baud rate deviation smod bit in pcon timer 1 c/t bit in tmod timer mode in tmod th1 reload value (hex) mode 0 max 40.0 3.33mhz 3.33mhz 0 x x x x mode 2 max 40.0 1250 k 1250 k 0 1 x x x mode 2 max 40.0 625 k 625 k 0 0 x x x modes 1 or 3 40.0 19200 18939 -1.36% 1 0 2 f5 modes 1 or 3 40.0 9600 9470 -1.36% 1 0 2 ea modes 1 or 3 36.0 19200 18570 -2.34% 1 0 2 f6 modes 1 or 3 33.333 57600 57870 0.47% 1 0 2 fd modes 1 or 3 33.333 28800 28934 0.47% 1 0 2 fa modes 1 or 3 33.333 19200 19290 0.47% 1 0 2 f7 modes 1 or 3 33.333 9600 9645 0.47% 1 0 2 ee modes 1 or 3 24.0 9600 9615 0.16% 1 0 2 f3 modes 1 or 3 12.0 4800 4808 0.16% 1 0 2 f3 modes 1 or 3 11.0592 57600 57600 0 1 0 2 ff modes 1 or 3 11.0592 28800 28800 0 1 0 2 fe modes 1 or 3 11.0592 19200 19200 0 1 0 2 fd modes 1 or 3 11.0592 9600 9600 0 1 0 2 fa modes 1 or 3 3.6864 19200 19200 0 1 0 2 ff modes 1 or 3 3.6864 9600 9600 0 1 0 2 fe modes 1 or 3 1.8432 9600 9600 0 1 0 2 ff modes 1 or 3 1.8432 4800 4800 0 1 0 2 fe
87/264 upsd34xx - serial uart interfaces more about uart mode 0 refer to the block diagram in figure 31., page 88 , and timing diagram in figure 32., page 88 . transmission is initiated by any instruction which writes to the sfr named sbuf. at the end of a write operation to sbuf, a 1 is loaded into the 9th position of the transmit shift register and tells the tx control unit to begin a transmission. transmis- sion begins on the following mcu machine cycle, when the ?send? signal is active in figure 32 . send enables the output of the shift register to the alternate function on the port containing pin rxd, and also enables the shift clock signal to the alternate function on the port containing the pin, txd. at the end of each shift clock in which send is active, the contents of the transmit shift register are shifted to the right one position. as data bits shift out to the right, zeros come in from the left. when the msb of the data byte is at the output position of the shift register, then the '1' that was initially loaded in to the 9th position, is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift, then deactivate send, and then set the interrupt flag ti. both of these actions occur at s1p1. reception is initiated by the condition ren = 1 and ri = 0. at the end of the next mcu machine cycle, the rx control unit writes the bits 11111110 to the receive shift register, and in the next clock phase activates receive. receive enables the shift clock signal to the alternate function on the port containing the pin, txd. each pulse of shift clock moves the contents of the receive shift register one position to the left while receive is active. the value that comes in from the right is the value that was sampled at the rxd pin. as data bits come in from the right, 1s shift out to the left. when the 0 that was initially loaded into the right- most position arrives at the left-most position in the shift register, it flags the rx control unit to do one last shift, and then it loads sbuf. after this, re- ceive is cleared, and the receive interrupt flag ri is set.
upsd34xx - serial uart interfaces 88/264 figure 31. uart mode 0, block diagram figure 32. uart mode 0, timing diagram ai06824 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift shift clock serial port interrupt f osc /12 ren r1 rx clock start tx clock start shift shift send receive t r cl ds q 7 6 5 4 3 2 1 0 rxd p3.0 alt input function rxd pin txd pin ai06825 write to sbuf send shift rxd (data out) txd (shift clock) ti write to scon ri receive shift rxd (data in) txd (shift clock) clear ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7
89/264 upsd34xx - serial uart interfaces more about uart mode 1 refer to the block diagram in figure 33., page 90 , and timing diagram in figure 34., page 90 . transmission is initiated by any instruction which writes to sbuf. at the end of a write operation to sbuf, a '1' is loaded into the 9th position of the transmit shift register and flags the tx control unit that a transmission is requested. transmission ac- tually starts at the end of the mcu the machine cy- cle following the next rollo ver in the divide-by-16 counter. thus, the bit times are synchronized to the divide-by-16 counter, not to the writing of sbuf. transmission begins with activation of send which puts the start bit at pin txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to pin txd. the first shift pulse occurs one bit time after that. as data bits shift out to the right, zeros are clocked in from the left. when the msb of the data byte is at the output position of the shift register, then the 1 that was initially loaded into the 9th position is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deac- tivates send, and sets the interrupt flag, ti. this occurs at the 10th divide-by-16 rollover after a write to sbuf. reception is initiated by a detected 1-to-0 transi- tion at the pin rxd. for this purpose rxd is sam- pled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset, and 1ffh is written into the input shift register. reset- ting the divide-by-16 counter aligns its rollovers with the boundaries of the incoming bit times. the 16 states of the counter divide each bit time into 16ths. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for another '1'-to- '0' transition. this is to provide rejection of false start bits. if the start bit proves valid, it is shifted into the input shift register, and reception of the re- set of the rest of the frame will proceed. as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left-most position in the shift register (which in mode 1 is a 9-bit reg- ister), it flags the rx control unit to do one last shift, load sbuf and rb8, and set the receive in- terrupt flag ri. the signal to load sbuf and rb8, and to set ri, will be generat ed if, and only if, the following conditions are met at the time the final shift pulse is generated: 1. ri = 0, and 2. either sm2 = 0, or the received stop bit = 1. if either of these two conditions are not met, the re- ceived frame is irretrievabl y lost. if both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. at this time, whether the above conditions are met or not, the unit goes back to looking for a '1'-to-'0' transition on pin rxd.
upsd34xx - serial uart interfaces 90/264 figure 33. uart mode 1, block diagram figure 34. uart mode 1, timing diagram ai06826 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06843 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit
91/264 upsd34xx - serial uart interfaces more about uart modes 2 and 3 for mode 2, refer to the block diagram in figure 35., page 92 , and timing diagram in figure 36., page 92 . for mode 3, refer to the block dia- gram in figure 37., page 93 , and timing diagram in figure 38., page 93 . keep in mind that the baud rate is programmable to either 1/32 or 1/64 of f osc in mode 2, but mode 3 uses a variable baud rate generated from timer 1 or timer 2 rollovers. the receive portion is exactly the same as in mode 1. the transmit portion differs from mode 1 only in the 9th bit of the transmit shift register. transmission is initiated by any instruction which writes to sbuf. at the end of a write operation to sbuf, the tb8 bit is loaded into the 9th position of the transmit shift register and flags the tx control unit that a transmission is requested. transmis- sion actually starts at the end of the mcu the ma- chine cycle following the next rollover in the divide- by-16 counter. thus, the bit times are synchro- nized to the divide-by-16 counter, not to the writing of sbuf. transmission begins with activation of send which puts the start bit at pin txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to pin txd. the first shift pulse occurs one bit time after that. the first shift clocks a '1' (the stop bit) into the 9th bit position of the shift register. there-after, only zeros are clocked in. thus, as data bits shift out to the right, zeros are clocked in from the left. when bit tb8 is at the output position of the shift register, then the stop bit is just to the left of tb8, and all po- sitions to the left of that contain zeros. this condi- tion flags the tx control unit to do one last shift and then deactivate send, and set the interrupt flag, ti. this occurs at the 11th divide-by 16 roll- over after writing to sbuf. reception is initiated by a detected 1-to-0 transi- tion at pin rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the di- vide-by-16 counter is immediately reset, and 1ffh is written to the input shift register. at the 7th, 8th, and 9th counter states of each bit time, the bit de- tector samples the value of rxd. the value ac- cepted is the value that was seen in at least 2 of the 3 samples. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for another '1'-to- '0' transition. if the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed . as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left-most position in the shift register (which in modes 2 and 3 is a 9-bit regis- ter), it flags the rx control unit to do one last shift, load sbuf and rb8, and set the interrupt flag ri. the signal to load sbuf and rb8, and to set ri, will be generated if, and on ly if, the following con- ditions are met at the time the final shift pulse is generated: 1. ri = 0, and 2. either sm2 = 0, or the received 9th data bit = 1. if either of these conditions is not met, the received frame is irretrievably lost, and ri is not set. if both conditions are met, the received 9th data bit goes into rb8, and the first 8 data bits go into sbuf. one bit time later, whether the above conditions were met or not, the unit goes back to looking for a '1'-to-'0' transition on pin rxd.
upsd34xx - serial uart interfaces 92/264 figure 35. uart mode 2, block diagram figure 36. uart mode 2, timing diagram ai06844 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 f osc /32 01 smod ai06845 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
93/264 upsd34xx - serial uart interfaces figure 37. uart mode 3, block diagram figure 38. uart mode 3, timing diagram ai06846 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06847 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
upsd34xx - irda interface 94/264 irda interface upsd34xx devices provide an internal irda inter- face that will allow the connection of the uart1 serial interface directly to an external infrared transceiver device. the irda interface does this by automatically shortening the pulses transmitted on uart1?s txd1 pin, and stretching the incoming pulses received on the rxd1 pin. reference fig- ures 39 and 40 . when the irda interface is enabled, the output sig- nal from uart1?s transmitter logic on pin txd1 is compliant with the irda ph ysical layer link spec- ification v1.4 (www.irda.org) operating from 1.2k bps up to 115.2k bps. the pulses received on the rxd1 pin are stretched by the irda interface to be recognized by uart1?s receiver logic, also adher- ing to the irda specification up to 115.2k bps. note: in figure 40 a logic '0' in the serial data stream of a uart frame corresponds to a logic high pulse in an ir frame. a logic '1' in a uart frame corresponds to no pulse in an ir frame. figure 39. irda interface figure 40. pulse shaping by the irda interface ua rt1 irda inter f ac e txd rxd upsd34xx ir da transceiver txd1-irda rx d1- ir da sirclk ai10437 start bit 0101 11 1 00 0 stop bit uart frame data bits bit time pulse width = 3/16 bit time start bit 0101 11 1 00 0 stop bit uart frame ir frame ir frame data bits ai10438
95/264 upsd34xx - irda interface the uart1 serial channel can operate in one of four different modes as shown in table 46., page 83 in the section, serial uart interfaces, page 83 . however, when uart1 is used for irda communication, uart1 must op- erate in mode 1 only, to be compatible with irda protocol up to 115.2k bps. the irda interface will support baud rates generated from timer 1 or tim- er 2, just like standard uart serial communica- tion, but with one restriction. the transmit baud rate and receive baud rate must be the same (can- not be different rates as is allowed by standard uart communications). the irda interface is disabled after a reset and is enabled by setting the irdaen bit in the sfr named irdacon ( table 50., page 95 ). when irda is disabled, the uart1's rxd and txd sig- nals will bypass the intern al irda logic and instead they are routed directly to the pins rxd1 and txd1 respectively. when irda is enabled, the irda pulse shaping logic is active and resides between uart1 and the pins rxd1 and txd1 as shown in figure 39., page 94 . baud rate selection the irda standard only supports 2.4, 9.6, 19.2, and 115.2kbps. table table 52., page 96 informs the irda interface of the baud rate of uart#2 so that it can perform pulse modulation properly. it may not be necessary to implement the br[3:0] bits in the irdacon register if the irda interface obtains the proper timing from uart#2. table 50. irdacon register bit definition (sfr ceh, reset value 0fh) table 51. baud rate selection register (sfr xxh, reset value xxh) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? irdaen pulse cdiv4 cdiv3 cdiv2 cdiv1 cdiv0 details bit symbol r/w definition 7 ? ? reserved 6 irdaen rw irda enable 0 = irda interface is disabled 1 = irda is enabled, uart1 outputs are disconnected from port 1 (or port 4) 5pulserw irda pulse modulation select 0 = 1.627s 1 = 3/16 bit time pulses 4-0 cdiv[4:0] rw specify clock divider (see table 53., page 97 ) bit symbol r/w definition 7:4 br[3:0] r,w specify baud rate (see table 52 ) 3:2 pulse r,w irda pulse modulation select 0 = 3/16 bit time pulses (not recommended) 1 = 1.627s 1:0 irdaen r,w 0 = irda interface is disabled 1 = irda is enabled, uart#2 outputs are disconnected from port 1 (or port 4)
upsd34xx - irda interface 96/264 table 52. baud rate of uart#2 for irda interface br3 br2 br1 br0 baud rate (kbps) 0 0 0 0 115.2 000157.5 001038.4 001119.2 010014.4 010112.8 01109.6 01117.2 10004.8 10013.6 10102.4 10111.8 11001.2
97/264 upsd34xx - irda interface pulse width selection the irda interface has two ways to modulate the standard uart1 serial stream: 1. an irda data pulse will have a constant pulse width for any bit time, regardless of the selected baud rate. 2. an irda data pulse will have a pulse width that is proportional to the the bit time of the selected baud rate. in this case, an irda data pulse width is 3/16 of its bit time, as shown in figure 40., page 94 . the pulse bit in the sfr named irdacon de- termines which met hod above will be used. according to the irda ph ysical layer specification, for all baud rates at 115.2k bps and below, the minimum data pulse width is 1.41s. for a baud rate of 115.2k bps, the maximum pulse width 2.23s. if a constant pulse width is to be used for all baud rates (pulse bit = 0), the ideal general pulse width is 1.63s, derived from the bit time of the fastest baud rate (8.68s bit time for 115.2k bps rate), multiplied by the proportion, 3/16. to produce this fixed data pulse width when the pulse bit = 0, a prescaler is needed to generate an internal reference clock, sirclk, shown in fig- ure 39., page 94 . sirclk is derived by dividing the oscillator clock frequency, f osc, using the five bits cdiv[4:0] in the sfr na med irdacon. a divisor must be chosen to produce a frequency for sirclk that lies between 1.34 mhz and 2.13 mhz, but it is best to choose a divisor value that produces sir- clk frequency as close to 1.83mhz as possible, because sirclk at 1.83mh z will produce an fixed irda data pulse width of 1.63s. table 53 provides recommended values for cdiv[4:0] based on sev- eral different values of f osc . for reference, sirclk of 2.13mhz will generate a fixed irda data pulse width of 1.41s, and sirclk of 1.34mhz will generate a fixed data pulse width of 2.23s. table 53. recommended cdiv[4:0] values to generate sirclk (default cdiv[4:0] = 0fh, 15 decimal) note: 1. when pulse bit = 0 (fixed data pulse width), this is minimum recommended f osc because cdiv[4:0] must be 4 or greater. f osc (mhz) value in cdiv[4:0] resulting f sirclk (mhz) 40.00 16h, 22 decimal 1.82 36.864, or 36.00 14h, 20 decimal 1.84, or 1.80 24.00 0dh, 13 decimal 1.84 11.059, or 12.00 06h, 6 decimal 1.84, or 2.00 7.3728 (1) 04h, 4 decimal 1.84
upsd34xx - i 2 c interface 98/264 i 2 c interface upsd34xx devices support one serial i 2 c inter- face. this is a two-wir e communication channel, having a bi-directional data signal (sda, pin p3.6) and a clock signal (scl, pin p3.7) based on open- drain line drivers, requiring external pull-up resis- tors, r p , each with a typical value of 4.7k ? (see figure 41 ). i 2 c interface main features byte-wide data is transferred, msb first, between a master device and a slave device on two wires. more than one bus master is allowed, but only one master may control the bus at any given time. data is not lost when another master requests the use of a busy bus because i 2 c supports collision de- tection and arbitration. the bus master initiates all data movement and generates the clock that per- mits the transfer. once a transfer is initiated by the master, any device addressed is considered a slave. automatic clock synchronization allows i 2 c devices with different bit rates to communicate on the same physical bus. a single device can play the role of master or slave, or a single device can be a slave only. each slave device on the bus has a unique address, and a general broadcast ad- dress is also available. a master or slave device has the ability to suspend da ta transfers if the de- vice needs more time to transmit or receive data. this i 2 c interface has the following features: ? serial i/o engine (sioe): serial/parallel conversion; bus arbitration; clock generation and synchronization; and handshaking are all performed in hardware ? interrupt or polled operation ? multi-master capability ? 7-bit addressing ? supports standard speed i 2 c (scl up to 100khz), fast mode i 2 c (101khz to 400khz), and high-speed mode i 2 c (401khz to 833khz) figure 41. typical i 2 c bus configuration note: 1. for 3.3v system, connect r p to 3.3v v cc . for 5.0v system, connect r p to 5.0v v dd . i 2 c bus sda scl r p r p v cc or v dd (1) device with i 2 c interface device with i 2 c interface sda/p3.6 scl/p3.7 upsd33xx(v) device with i 2 c interface ai09623
99/264 upsd34xx - i 2 c interface communication flow i 2 c data flow control is based on the fact that all i 2 c compatible devices will drive the bus lines with open-drain (or open-collector) line drivers pulled up with external resistors, creating a wired-and situation. this means that either bus line (sda or scl) will be at a logic '1' level only when no i 2 c de- vice is actively driving the line to logic '0.' the logic for handshaking, arbitration, synchronization, and collision detection is im plemented by each i 2 c de- vice having: 1. the ability to hold a line low against the will of the other devices who are trying to assert the line high. 2. the ability of a device to detect that another device is driving the line low against its will. assert high means the driver releases the line and external pull-ups passively raise the signal to logic '1.' holding low means th e open-drain driver is actively pulling the signal to ground for a logic '0.' for example, if a slave device cannot transmit or receive a byte because it is distracted by and inter- rupt or it has to wait for some process to complete, it can hold the scl clock line low. even though the master device is generating the scl clock, the master will sense that the slave is holding the scl line low against the will of the master, indicating that the master must wait until the slave releases scl before proceeding with the transfer. another example is when two master devices try to put information on the bus simultaneously, the first one to release the sda data line looses arbi- tration while the winner c ontinues to hold sda low. two types of data transfers are possible with i 2 c depending on the r/w bit, see figure 42., page 100 . 1. data transfer from master transmitter to slave receiver (r/w = 0). in this case, the master generates a start condition on the bus and it generates a clock signal on the scl line. then the master transmits the first byte on the sda line containing the 7-bit slave address plus the r/w bit. the slave who owns that address will respond with an acknowledge bit on sda, and all other slave devices will not respond. next, the master will transmit a data byte (or bytes) that the addressed slave must receive. the slave will return an acknowledge bit after each data byte it successfully receives. after the final byte is transmitted by the master, the master will generate a stop condition on the bus, or it will generate a re- start conditon and begin the next transfer. there is no limit to the number of bytes that can be transmitted during a transfer session. 2. data transfer from slave transmitter to master receiver (r/w = 1). in this case, the master generates a start condition on the bus and it generates a clock signal on the scl line. then the master transmits the first byte on the sda line containing the 7-bit slave address plus the r/w bit. the slave who owns that address will respon d with an acknowledge bit on sda, and all ot her slave devices will not respond. next, the ad dressed slave will transmit a data byte (or bytes) to the master. the master will return an acknowledge bit after each data byte it successfully receives, unless it is the last byte the master desires. if so, the master will not acknowledge the last byte and from this, the slave knows to stop transmitting data bytes to the master. the master will then generat e a stop condition on the bus, or it will generate a re-start conditon and begin the next transfer. there is no limit to the number of bytes that can be transmitted during a transfer session. a few things to know related to these transfers: ? either the master or slave device can hold the scl clock line low to in dicate it needs more time to handle a byte transfer. an indefinite holding period is possible. ? a start condition is generated by a master and recognized by a slave when sda has a 1- to-0 transition while scl is high ( figure 42., page 100 ). ? a stop condition is generated by a master and recognized by a slave when sda has a 0- to1 transition while scl is high ( figure 42., page 100 ). ? a re-start (repeated start) condition generated by a master can have the same function as a stop condition when starting another data transfer immediately following the previous data transfer ( figure 42., page 100 ). ? when transferring data, the logic level on the sda line must remain stable while scl is high, and sda can change only while scl is low. however, when not transferring data, sda may change state while scl is high, which creates the start and stop bus conditions.
upsd34xx - i 2 c interface 100/264 ? an acknowlegde bit is generated from a master or a slave by driving sda low during the ?ninth? bit time, ju st following each 8-bit byte that is transfered on the bus ( figure 42., page 100 ). a non-acknowledge occurs when sda is asserted high during the ninth bit time. all byte transfers on the i 2 c bus include a 9th bit time reserved for an acknowlege (ack) or non-acknowledge (nack). ? an additional master device that desires to control the bus should wait until the bus is not busy before generating a start condition so that a possible slave operation is not interrupted. ? if two master devices both try to generate a start condition simultaneously, the master who looses arbitration will switch immediately to slave mode so it can recoginize its own slave address should it appear on the bus. figure 42. data transfer on an i 2 c bus msb 7-bit slave address read/write indicator acknowledge bits from receiver start condition clock can be held low to stall transfer. repeated if more data bytes are transferred. repeated start condition stop condition 12 789 3-6 1 2 9 3-8 msb ack ack nack r/w ai09625
101/264 upsd34xx - i 2 c interface operating modes the i 2 c interface supports four operating modes: master-transmitter master-receiver slave-transmitter slave-receiver the interface may operate as either a master or a slave within a given application, controlled by firm- ware writing to sfrs. by default after a reset, the i 2 c interface is in mas- ter receiver mode, and the sda/p3.6 and scl/ p3.7 pins default to gpio input mode, high imped- ance, so there is no i 2 c bus interference. before using the i 2 c interface, it mu st be initialized by firmware, and the pins must be configured. this is discussed in i 2 c operating sequences, page 111 . bus arbitration a master device always samples the i 2 c bus to ensure a bus line is high whenever that master is asserting a logic 1. if the lin e is low at that time, the master recognizes another device is overriding its own transmission. a master may start a transfer only if the i 2 c bus is not busy. however, it is possible that two or more masters may generate a start condition simulta- neously. in this case, arbitration takes place on the sda line each time scl is high. the master that first senses that its bus sample does not corre- spond to what it is driving (sda line is low while it is asserting a high) will immediately change from master-transmitter to slave-receiver mode. the arbitration process can carry on for many bit times if both masters are addressing the same slave de- vice, and will continue into the data bits if both masters are trying to be master-transmitter. it is also possible for arbitration to carry on into the ac- knowledge bits if both masters are trying to be master-receiver. because address and data in- formation on the bus is determined by the winning master, no information is lost during the arbitration process. clock synchronization clock synchronization is used to synchronize arbi- trating masters, or used as a handshake by a de- vices to slow down the data transfer. clock sync during arbitration. during bus ar- bitration between competing masters, master_x, with the longest low period on scl, will force master_y to wait until ma ster_x finishes its low period before master_y proceeds to assert its high period on scl. at this point, both masters begin asserting their high period on scl simultaneously, and the master with the s hortest high period will be the first to drive scl for the next low period. in this scheme, the master with the longest low scl pe- riod paces low times, and the master with the shortest high scl period paces the high times, making synchronized arbitration possible. clock sync during handshaking. this allows receivers in different devices to handle various transfer rates, either at the byte-level, or bit-level. at the byte-level, a device may pause the transfer between bytes by holding scl low to have time to store the latest received byte or fetch the next byte to transmit. at the bit-level, a slave device may extend the low period of scl by holding it low. thus the speed of any master device will adap t to the internal opera- tion of the slave. general call address a general call (gc) occurs when a master-trans- mitter initiates a transfer containing a slave ad- dress of 0000000b, and the r/w bit is logic 0. all slave devices capable of responding to this broad- cast message will ackno wledge the gc simulta- neously and then behave as a slave-receiver. the next byte transmitted by the master will be ac- cepted and acknowledged by all slaves capable of handling the special data bytes. a slave that can- not handle one of these data bytes must ignore it by not acknowledging it. the i 2 c specification lists the possible meanings of the special bytes that fol- low the first gc address byte, and the actions to be taken by the slave device(s) upon receiving them. a common use of the gc by a master is to dynamically assign device addresses to slave de- vices on the bus capable of a programmable de- vice address. the upsd34xx can generate a gc as a master- transmitter, and it can receive a gc as a slave. when receiving a gc address (00h), an interrupt will be generated so firmwa re may respond to the special gc data bytes if desired.
upsd34xx - i 2 c interface 102/264 serial i/o engine (sioe) at the heart of the i 2 c interface is the hardware sioe, shown in figure 43 . the sioe automatically handles low-level i 2 c bus protocol (data shifting, handshaking, arbitration, clock generation and synchronization) and it is controlled and monitored by five sfrs. the five sfrs shown in figure 43 are: s1con - interface control ( table 54., page 103 ) s1sta - interface status ( table 56., page 106 ) s1dat - data shift register ( table 57., page 107 ) s1adr - device address ( table 58., page 107 ) s1setup - sampling rate ( table 59., page 108 ) figure 43. i 2 c interface sioe block diagram open- drain output input open- drain output input comparator s1setup - sample rate control (start condition) s1sta - interface status s1con - interface control ack bit scl / p3.7 timing and control clock generation arbitration and sync periph clock (f osc ) sda / p3.6 8032 mcu bus intr to 8032 s1dat - shift register serial data in serial data out shift direction 8 8 8 8 8 7 7 b0 b7 s1adr - device address b7 b0 ai09626
103/264 upsd34xx - i 2 c interface i 2 c interface control register (s1con) table 54. serial control register s1con (sfr dch, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 cr2 eni1 sta sto addr aa cr[1:0] details bit symbol r/w function 7 cr2 r,w this bit, along with bits cr1 and cr0, determine the scl clock frequency (f scl ) when sioe is in master mode. these bits create a clock divisor for f osc . see table 55 . 6eni1r,w i 2 c interface enable 0 = sioe disabled, 1 = sioe enabled. when disabled, both sda and scl signals are in high impedance state. 5star,w start flag. when set, master mode is entered and sioe generates a start condition only if the i 2 c bus is not busy. when a start condition is detected on the bus, the sta flag is cleared by hardware. when the sta bit is set during an interrupt service, the start condition will be generated after the interrupt service. 4stor,w stop flag when sto is set in master mode, t he sioe generates a stop condition. when a stop condition is detected, the sto flag is cleared by hardware. when the sto bit is set dur ing an interrupt service, the stop condition will be generated after the interrupt service. 3 addr r,w this bit is set when an address byte received in slave mode matches the device address programmed into the s1adr register. the addr bit must be cleared with firmware. 2aar,w assert acknowledge enable if aa = 1, an acknowledge signal (low on sda) is automatically returned during the acknowledge bit-time on the scl line when any of the following three events occur: 1. sioe in slave mode receives an address that matches contents of s1adr register 2. a data byte has been received while sioe is in master receiver mode 3. a data byte has been received while sioe is a selected slave receiver when aa = 0, no acknowledge is returned (high on sda during acknowl- edge bit-time). 1, 0 cr1, cr0 r,w these bits, along with bit cr2, determine the scl clock frequency (f scl ) when sioe is in master mode. thes e bits create a clock divisor for f osc . see table 55 for values.
upsd34xx - i 2 c interface 104/264 table 55. selection of the scl frequency in master mode based on f osc examples note: 1. these values are beyond the bit rate supported by upsd34xx. cr2 cr1 cr0 f osc divided by: bit rate (khz) @ f osc 12mhz f osc 24mhz f osc 36mhz f osc 40mhz f osc 0 0 0 32 375 750 x (1) x (1) 0 0 1 48 250 500 750 833 0 1 0 60 200 400 600 666 0 1 1 120 100 200 300 333 1 0 0 240 50 100 150 166 1 0 1 480 25 50 75 83 1 1 0 960 12.5 25 37.5 41 1 1 1 1920 6.25 12.5 18.75 20
105/264 upsd34xx - i 2 c interface i 2 c interface status register (s1sta) the s1sta register provides status regarding im- mediate activity and the current state of operation on the i 2 c bus. all bits in this register are read-only except bit 5, intr, which is the interrupt flag. interrupt conditions. if the i 2 c interrupt is en- abled (ei 2 c = 1 in sfr named iea, and ea =1 in sfr named ie), and the sioe is initialized, then an interrupt is automatically generated when any one of the following five events occur: ? when the sioe receives an address that matches the contents of the sfr, s1adr. requirements: sioe is in slave mode, and bit aa = 1 in the sfr s1con. ? when the sioe receives general call address. requirments: sioe is in slave mode, bit aa = 1 in the sfr s1con ? when a complete data byte has been received or transmitted by the sioe while in master mode. the interrupt will occur even if the master looses arbitration. ? when a complete data byte has been received or transmitted by the s ioe while in selected slave mode. ? a stop condition on the bus has been recognized by the sioe while in selected slave mode. selected slave mode means the device address sent by the master device at the beginning of the current data transfer matched the address stored in the s1adr register. if the i 2 c interrupt is not enabled, the mcu may poll the intr flag in s1sta.
upsd34xx - i 2 c interface 106/264 table 56. s1sta: i 2 c interface status register (sfr ddh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 gc stop intr tx_mode bbusy blost ack_resp slv details bit symbol r/w function 7gcr general call flag gc = 1 if the general call address of 00h was received when sioe is in slave mode, and gc is cleared by a start or stop condition on the bus. if the sioe is in master m ode when gc = 1, the bus lost condition exists, and blost = 1. 6stopr stop flag stop = 1 while sioe detects a stop condition on the bus when in master or slave mode. 5intrr,w interrupt flag intr is set to 1 by any of the five i 2 c interrupt conditions listed above. intr must be cleared by firmware. 4tx_moder transmission mode flag tx_mode = 1 whenever the sioe is in master-transmitter or slave- transmitter mode. tx_mode = 0 when sioe is in any receiver mode. 3bbusyr bus busy flag bbusy = 1 when the i 2 c bus is in use. bbusy is set by the sioe when a start condition exists on the bus and bbusy is cleared by a stop condition. 2blostr bus lost flag blost is set when the sioe is in master mode and it looses the arbitration process to another master device on the bus. 1 ack_resp r not acknowledge response flag while sioe is in transmitter mode: ? after sioe sends a byte, ack_resp = 1 whenever the external i 2 c device receives the byte, but that device does not assert an ackowledge signal (external device asserted a high on sda during the acknowledge bit-time). ? after sioe sends a byte, ack_resp = 0 whenever the external i 2 c device receives the byte, and that device does assert an ackowledge signal (external device drove a low on sda during the acknowledge bit-time) note: if sioe is in master-transmitter mode, and ack_resp = 1 due to a slave-transmitter not sending an acknowledge, a stop condition will not automatically be generated by t he sioe. the stop condition must be generated with s1con.sto = 1. 0slvr slave mode flag slv = 1 when the sioe is in slave mode. slv = 0 when the sioe is in master mode (default).
107/264 upsd34xx - i 2 c interface i 2 c data shift register (s1dat) the s1adr register (table 57 ) holds a byte of se- rial data to be transmitted or it holds a serial byte that has just been received. the mcu may access s1dat while the sioe is not in the process of shifting a byte (the intr flag indicates shifting is complete). while transmitting, bytes are shifted out msb first, and when receiving, bytes are shifted in msb first, through the acknowledge bit register as shown in figure 43., page 102 . bus wait condition. after the sioe finishes re- ceiving a byte in receive mode, or transmitting a byte in transmit mode, the intr flag (in s1sta) is set and automatically a wait condition is im- posed on the i 2 c bus (scl held low by sioe). in transmit mode, this wait condition is released as soon as the mcu writes any byte to s1dat. in re- ceive mode, the wait conditi on is released as soon as the mcu reads the s1dat register. this method allows the user to handle transmit and receive operations within an interrupt service routine. the sioe will au tomatically stall the i 2 c bus at the appropriate time, giving the mcu time to get the next byte ready to transmit or time to read the byte that was just received. table 57. s1dat: i 2 c data shift register (sfr deh, reset value 00h) i 2 c address register (s1adr) the s1adr register (table 58 ) holds the 7-bit de- vice address used when the sioe is operating as a slave. when the sioe receives an address from a master, it will compare this address to the con- tents of s1adr, as shown in figure 43., page 102 . if the 7 bits match, the intr interrupt flag (in s1sta) is set, and the addr bit (in s1con) is set. the sioe cannot modify the contents s1adr, and s1adr is not used during master mode. table 58. s1adr: i 2 c address register (sfr dfh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 s1dat[7:0] details bit symbol r/w function 7:0 s1dat[7:0] r/w holds the data byte to be transmitted in transmit mode, or it holds the data byte received in receiver mode. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sla6 sla5 sla4 sla3 sla2 sla1 sla0 ? details bit symbol r/w function 7:1 sla[6:0] r/w stores desired 7-bit device ad dress, used when sioe is in slave mode. 0 ? ? not used
upsd34xx - i 2 c interface 108/264 i 2 c start sample setting (s1setup) the s1setup register (table 59 ) determines how many times an i 2 c bus start condition will be sampled before the sioe validates the start condition, giving the sioe the ability to reject noise or illegal transmissions. because the minimum duration of an start con- dition varies with i 2 c bus speed (f scl ), and also because the upsd34xx may be operated with a wide variety of frequencies (f osc ), it is necessary to scale the number of samples per start condi- tion based on f osc and f scl . in slave mode, the sioe recognizes the beginning of a start condition when it detects a '1'-to-'0' transition on the sda bus line while the scl line is high (see figure 42., page 100 ). the sioe must then validate the start condition by sampling the bus lines to ensure sda remains low and scl re- mains high for a minimum amount of hold time, t hldsta . once validated, the sioe begins receiv- ing the address byte that follows the start con- dition. if the en_ss bit (in the s1setup register) is not set, then the sioe will sa mple only once after de- tecting the '1'-to-'0' transition on sda. this single sample is taken 1/f osc seconds after the initial 1- to-0 transition was detected. however, more sam- ples should be taken to ensure there is a valid start condition. to take more samples, th e sioe should be initial- ized such that the en_ss bit is set, and a value is written to the smpl_set[6:0] field of the s1setup register to specify how many samples to take. the goal is to take a good number of sam- ples during the minimum start condition hold time, t hldsta , but no so many samples that the bus will be sampled after t hldsta expires. table 60., page 109 describes the relationship be- tween the contents of s1setup and the resulting number of i 2 c bus samples that sioe will take af- ter detecting the 1-to-0 transition on sda of a start condition. important: keep in mind that the time between samples is always 1/f osc . the minimum start condition hold time, t hlds- ta , is different for the three common i 2 c speed categories per table 61., page 109 . table 59. s1setup: i 2 c start condition sample setup register (sfr dbh, reset value 00h) note: 1. sampling scl and sda lines begins after '1'-to-'0' transition on sda occurred while scl is high. time between samples is 1/f osc . bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 en_ss smpl_set[6:0] details bit symbol r/w function 7en_ssr/w enable sample setup en_ss = 1 will force the sioe to sample (1) a start condition on the bus the number of times specified in smpl_set[6:0]. en_ss = 0 means the sioe will sample (1) a start condition only one time, regardless of the c ontents of smpl_set[6:0]. 6:0 smpl_set [6:0] ? sample setting specifies the number of bus samples (1) taken during a start condition. see table 60 for values.
109/264 upsd34xx - i 2 c interface table 60. number of i 2 c bus samples taken after 1-to-0 transition on sda (start condition) table 61. start condition hold time note: 1. 833khz is maximum for upsd34xx devices. contents of s1setup resulting value for s1setup resulting number of samples taken after 1-to-0 on sda line ss_en bit smpl_set[6:0] 0 xxxxxxxb 00h (default) 1 1 0000000b 80h 1 1 0000001b 81h 2 1 0000010b 82h 3 ... ... ... ... 1 0001011b 8bh 12 1 0010111b 97h 24 ... ... ... ... 1 1111111b ffh 128 i 2 c bus speed range of i 2 c clock speed (f scl ) minimum start condition hold time ( t hldsta ) standard up to 100khz 4000ns fast 101khz to 400khz 600ns high 401khz to 833khz (1) 160ns
upsd34xx - i 2 c interface 110/264 table 62 provides recommended settings for s1setup based on various combinations of f osc and f scl . note that the ?total sample period? times in table 61., page 109 are typically slightly less than the minimum start condition hold time, t hldsta for a given i 2 c bus speed. important: the scl bit rate f scl must first be de- termined by bits cr[2:0] in the sfr s1con be- fore a value is chosen for smpl_set[6:0] in the sfr s1setup. table 62. s1setup examples for various i 2 c bus speeds and oscillator frequencies note: 1. not compatible with high speed i 2 c. i 2 c bus speed, f scl parameter oscillator frequency, f osc 6 mhz 12 mhz 24 mhz 33 mhz 40 mhz standard recommended s1setup value 93h a7h cfh eeh ffh number of samples 20 40 80 111 128 time between samples 166.6ns 83.3ns 41.6ns 30ns 25ns total sampled period 3332ns 3332ns 3332ns 3333ns 3200ns fast recommended s1setup value 82h 85h 8bh 90h 93h number of samples 3 6 12 17 20 time between samples 166.6ns 83.3ns 41.6ns 30ns 25ns total sampled period 500ns 500ns 500ns 510ns 500ns high recommended s1setup value (note 1) 80 82 83 84 number of samples - 1 3 4 5 time between samples - 83.3ns 41.6ns 30ns 25ns total sampled period - 83.3 125ns 120ns 125ns
111/264 upsd34xx - i 2 c interface i 2 c operating sequences the following pseudo-code explains hardware control for these i 2 c functions on the upsd34xx: ? initialize the interface ? function as master-transmitter ? function as master-receiver ? function as slave-transmitter ? function as slave-receiver ? interrupt service routine full c code drivers for the upsd34xx i 2 c inter- face, and other interfaces are available from the web at www.st.com\psm. initialization after a upsd34xx reset ensure pins p3.6 and p3.7 are gpio in- puts ? sfr p3.7 = 1 and sfr p3.6 = 1 configure pins p3.6 and p3.7 as i 2 c ? sfr p3sfs.6 = 1 and p3sfs.7 = 1 set i 2 c clock prescaler to determine f scl ? sfr s1con.cr[2:0] = desired scl freq. set bus start condition sampling ? sfr s1setup[7:0] = number of sam- ples enable individual i 2 c interrupt and set priority ? sfr iea.i2c = 1 ? sfr ipa.i2c = 1 if high priority is desired set the device address for slave mode ? sfr s1adr = xxh, desired address enable sioe (as slave) to return an ack signal ? sfr s1con.aa = 1 master-transmitter disable all interrupts ? sfr ie.ea = 0 set pointer to global data xmit buff- er, set count ? *xmit_buf = *pointer to data ? buf_length = number of bytes to xmit set global variables to indicate mas- ter-xmitter ? i2c_master = 1, i2c_xmitter = 1 disable master from returning an ack ? sfr s1con.aa = 0 enable i2c sioe ? sfr s1con.ini1 = 1 transmit address and r/w bit = 0 to slave ? is bus not busy? (sfr s1sta.bbusy = 0?) ? sfr s1dat[7:0] = load slave ad- dress & feh ? sfr s1con.sta = 1, send start on bus enable all interrupts and go do some- thing else ? sfr ie.ea = 1 master-receiver disable all interrupts ? sfr ie.ea = 0 set pointer to global data recv buff- er, set count ? *recv_buf = *pointer to data ? buf_length = number of bytes to recv set global variables to indicate mas- ter-xmitter ? i2c_master = 1, i2c_xmitter = 0 disable master from returning an ack ? sfr s1con.aa = 0 enable i2c sioe ? sfr s1con.ini1 = 1 transmit address and r/w bit = 1 to slave ? is bus not busy? (sfr s1sta.bbusy = 0?) ? sfr s1dat[7:0] = load slave ad- dress # 01h ? sfr s1con.sta = 1, send start on bus enable all interrupts and go do some- thing else ? sfr ie.ea = 1
upsd34xx - i 2 c interface 112/264 slave-transmitter disable all interrupts ? sfr ie.ea = 0 set pointer to global data xmit buff- er, set count ? *xmit_buf = *pointer to data ? buf_length = number of bytes to xmit set global variables to indicate mas- ter-xmitter ? i2c_master = 0, i2c_xmitter = 1 enable sioe ? sfr s1con.ini1 = 1 prepare to xmit first data byte ? sfr s1dat[7:0] = xmit_buf[0] enable all interrupts and go do some- thing else ? sfr ie.ea = 1 slave-receiver disable all interrupts ? sfr ie.ea = 0 set pointer to global data recv buff- er, set count ? *recv_buf = *pointer to data ? buf_length = number of bytes to recv set global variables to indicate mas- ter-xmitter ? i2c_master = 0, i2c_xmitter = 0 enable sioe ? sfr s1con.ini1 = 1 enable all interrupts and go do some- thing else ? sfr ie.ea = 1 interrupt service routine (isr). a typical i 2 c interrupt service routine would handle a interrupt for any of the four combinations of master/slave and transmitter/receiver. in the example routines above, the firmware sets global variables, i2c_master and i2c_xmitter, before enabling in- terrupts. these flags tell the isr which one of the four cases to process. following is pseudo-code for high-level steps in the i 2 c isr: begin i 2 c isr : clear i2c interrupt flag: ? s1sta.intr = 0 read status of sioe, put in to vari- able, status ? status = s1sta read global variables that determine the mode ? mode <= (i2c_master, i2c_slave) if mode is master-transmitter bus arbitration lost? (sta- tus.blost=1?) if yes, arbitration was lost: ? s1dat = dummy, write to release bus ? exit isr, sioe will switch to slave recv mode if no, arbitration was not lost, continue: ack recvd from slave? (sta- tus.ack_resp=0?) if no, an ack was not received: ? s1con.sto = 1, set stop bus condi- tion ? ? s1dat = dummy, write to release bus ? exit isr if yes, ack was received, then continue: ? s1dat = xmit_buf[buffer_index], transmit byte was that the last byte of data to transmit? if no, it was not the last byte, then: ? exit isr, transmit next byte on next interrupt if yes, it was the last byte, then: ? s1con.sto = 1, set stop bus condi- tion ? s1dat = dummy, write to release bus ? exit isr
113/264 upsd34xx - i 2 c interface else if mode is master-receiver: bus arbitration lost? (sta- tus.blost=1?) if yes, arbitration was lost: ? s1dat = dummy, write to release bus ? exit isr, sioe will switch to slave recv mode if no, aribitration was not lost, continue: is this interrupt from sending an ad- dress to slave, or is it from receiv- ing a data byte from slave? if its from sending slave ad- dress, goto a: if its from receiving slave da- ta, goto b: a: (interrupt is from master sending addr to slave) ack recvd from slave? (sta- tus.ack_resp=0?) if no, an ack was not received: ? s1con.sto = 1, set stop condition ? dummy = s1dat, read to release bus ? exit isr if yes, ack was received, then continue: ? dummy = s1dat, read to release bus does master want to receive just one data byte? if yes, do not allow master to ack on next interrupt: ? exit isr, now ready to recv one byte from slv if no, master can ack next byte from slv ? s1con.aa = 1, allow master to send ack ? exit isr, now ready to recv data from slave b: (interrupt is from master recving data from slv) ? recv_buf[buffer_index] = s1dat, read byte is this the last data byte to receive from slave? if yes, tell slave to stop transmitting: ? s1con.sto = 1, set stop bus condi- tion ? exit isr, finished receiving data from slave if no, continue: is this the next to last byte to re- ceive from slave? if this is the next to last byte, do not allow master to ack on next interrupt. ? s1con.aa = 0, don?t let master re- turn ack ? exit isr, now ready to recv last byte from slv if this is not next to last byte, let master send ack to slave ? exit isr, ready to recv more bytes from slave else if mode is slave-transmitter: is this intr from sioe detecting a stop on bus? if yes, a stop was detected: ? s1dat = dummy, write to release bus ? exit isr, master needs no more data bytes if no, a stop was not detected, continue: ack recvd from master? (sta- tus.ack_resp=0?) if no, an ack was not received: ? s1dat = dummy, write to release bus ? exit isr, master needs no more data bytes if yes, ack was received, then continue: ? s1dat = xmit_buf[buffer_index], transmit byte ? exit isr, transmit next byte on next interrupt
upsd34xx - i 2 c interface 114/264 else if mode is slave-receiver: is this intr from sioe detecting a stop on bus? if yes, a stop was detected: ? recv_buf[buffer_index] = s1dat, get last byte ? exit isr, master has sent last byte if no, a stop was not detected, continue: determine if this interrupt is from receiving an address or a data byte from a master. is (s1con.addr = 1 and s1con.aa =1)? if no, intr is from receiving data, goto c: if yes, intr is from an address, continue: ? slave_is_adressed = 1, local vari- able set true ? s1con.addr = 0, clear address match flag determine if r/w bit indicates trans- mit or receive. does status.tx_mode = 1? if yes, master wants transmit mode ? exit isr, indicate master wants slv-xmit mode if no, master wants slave-recv mode ? dummy = s1dat, read to release bus ? exit isr, ready to recv data on next interrupt c: (interrupt is from slv receiving data from mastr) ? recv_buf[buffer_index] = s1dat, read byte ? exit isr, recv next byte on next interrupt
115/264 upsd34xx - spi (synchronous peripheral interface) spi (synchronous peripheral interface) upsd34xx devices support one serial spi inter- face in master mode only. this is a three- or four- wire synchronous communication channel, capa- ble of full-duplex operation on 8-bit serial data transfers. the four spi bus signals are: spirxd pin p1.5 or p4.5 receives data from the slave spi device to the upsd34xx spitxd pin p1.6 or p4.6 transmits data from the upsd34xx to the slave spi device spiclk pin p1.4 or p4.4 clock is generated from the upsd34xx to the spi slave device spisel pin p1.7 or p4.7 selects the signal from the upsd34xx to an individual slave spi device this spi interface suppor ts single-master/multi- ple-slave connections. multiple-master connec- tions are not directly supported by the upsd34xx (no internal logic for collision detection). if more than one slave device is required, the spisel signal may be generated from upsd34xx gpio outputs (one for each slave) or from the pld outputs of the psd module. figure 44. illus- trates three examples of spi device connections using the upsd34xx: single-master/single-slave with spisel single-master/single-slave without spisel single-master/multiple-slave without spisel figure 44. spi device connection examples spi bus spi bus spi bus spitxd spirxd upsd34xx spi master spi slave device spiclk spisel ai07853b mosi miso sclk single-master/single-slave, with spisel single-master/single-slave, without spisel single-master/multiple-slave, without spisel ss spi slave device mosi miso sclk ss spi slave device mosi miso sclk ss ss spitxd spirxd upsd34xx spi master spi slave device spiclk spitxd spirxd upsd34xx spi master spiclk gpio or pld gpio or pld mosi miso sclk
upsd34xx - spi (synchronous peripheral interface) 116/264 spi bus features and communication flow the spiclk signal is a gated clock generated from the upsd34xx (master) and regulates the flow of data bits. the master may transmit at a va- riety of baud rates, and the spiclk signal will clock one period for each bit of transmitted data. data is shifted on one edge of spiclk and sam- pled on the opposite edge. the spitxd signal is generated by the master and received by the slave device. the spirxd signal is generated by the slave device and received by the master. there may be no more than one slave device transmitting data on spirxd at any given time in a multi-slave conf iguration. slave selection is accomplished when a slave?s ?slave select? (ss) input is permanently grounded or asserted active-low by a master device. slave devices that are not selected do not interfere with spi activities. slave devices ignore spiclk and keep their miso output pins in high-impedance state when not selected. the spi specification allows a selection of clock polarity and clock phase with respect to data. the upsd34xx supports the choice of clock polarity, but it does not support the choice of clock phase (phase is fixed at what is typically known as cpha = 1). see figure 46. and figure 47., page 117 for spi data and clock relationships. referring to these figures ( 46 and 47 ), when the phase mode is defined as such (fixed at cpha =1), in a new spi data frame, the master device begins driving the first data bit on spitxd at the very first edge of the first clock period of spi- clk. the slave device will use this first clock edge as a transmission start indicator, and therefore the slave?s slave select input signal may remain grounded in a single-master/single-slave configu- ration (which means the user does not have to use the spisel signal from upsd34xx in this case). the spi specification does not specify high-level protocol for data exchange, only low-level bit-seri- al transfers are defined. full-duplex operation when an spi transfer occurs, 8 bits of data are shifted out on one pin while a different 8 bits of data are simultaneously shifted in on a second pin. another way to view this transfer is that an 8-bit shift register in the master and another 8-bit shift register in the slave are connected as a circular 16-bit shift register. when a transfer occurs, this distributed shift register is shifted 8 bit positions; thus, the data in the master and slave devices are effectively exchanged (see figure 45. ). bus-level activity figure 46. details an spi receive operation (with respect to bus master) and figure 47. details an spi transmit operation. also shown are internal flags available to firmware to manage data flow. these flags are accessed through a number of sfrs. note: the upsd34xx spi interface sfrs allow the choice of transmitting the most significant bit (msb) of a byte first, or the least significant bit (lsb) first. the same bit-order applies to data re- ception. figures 46 and 47 illustrate shifting the lsb first. figure 45. spi full-duplex data exchange spi bus slave device master device ai10485 ss spitxd spirxd baud rate generator 8-bit shift register 8-bit shift register spiclk mosi miso sclk
117/264 upsd34xx - spi (synchronous peripheral interface) figure 46. spi receive operation example figure 47. spi transmit operation example bit7 spiclk (spo=0) spiclk (spo=1) spirxd bit0 bit1 bit7 bit0 bit1 bit7 1 frame risf roris busy spiintr spirdr full interrupt requested interrupt handler read data in spirdr spirdr full interrupt requested transmit end interrupt requested ai07855 bit0 spiclk (spo=0) spiclk (spo=1) spitxd bit1 bit7 bit0 bit1 bit7 1 frame tisf teisf busy spiintr spitdr empty interrupt requested interrupt handler write data in tdr spitdr empty interrupt requested transmit end interrupt requested spisel ai07854
upsd34xx - spi (synchronous peripheral interface) 118/264 spi sfr registers six sfr registers control the spi interface: spicon0 ( table 63., page 120 ) for interface control spicon1 ( table 64., page 121 ) for interrupt control spitdr (sfr d4h, write only) holds byte to transmit spirdr (sfr d5h, read only) holds byte received spiclkd ( table 65., page 121 ) for clock divider spistat ( table 66., page 122 ) holds interface status the spi interface functional block diagram ( figure 48. ) shows these six sfrs. both the transmit and receive data paths are double-buffered, meaning that continuous transmitting or receiving (back-to- back transfer) is possible by reading from spirdr or writing data to spitdr while shifting is taking place. there are a number of flags in the spistat register that indicate when it is full or empty to as- sist the 8032 mcu in data flow management. when enabled, these status flags will cause an in- terrupt to the mcu. figure 48. spi interface, master mode only spitdr - transmit register spitxd / p1.6 or p4.6 timing and control (f osc ) intr to 8032 spirdr - receive register 8-bit shift register 8 8 8 8 spirxd / p1.5 or p4.5 spicon0, spicon1 - control registers 8 spistat - status register 8 8032 mcu data bus clock generate spisel / p1.7 or p4.7 spiclk / p1.4 or p4.4 clock divide 1 4 8 16 32 64 128 spiclkd - divide select 8 periph_clk ai10486
119/264 upsd34xx - spi (synchronous peripheral interface) spi configuration the spi interface is reset by the mcu reset, and firmware needs to init ialize the sfrs spicon0, spicon1, and spiclkd to define several opera- tion parameters. the spo bit in spicon0 determines the clock po- larity. when spo is set to '0,' a data bit is transmit- ted on spitxd from one rising edge of spiclk to the next and is guaranteed to be valid during the falling edge of spiclk. when spo is set to '1,' a data bit is transmitted on spitxd from one falling edge of spiclk to the next and is guaranteed to be valid during the rising edge of spiclk. the upsd34xx will sample received data on the appro- priate edge of spiclk as determined by spo. the effect of the spo bit can be seen in figure 46. and figure 47., page 117 . the flsb bit in spicon0 determines the bit order while transmitting and receiving the 8-bit data. when flsb is '0,' the 8-bit data is transferred in or- der from msb (first) to lsb (last). when flsb bit is set to '1,' the data is transferred in order from lsb (first) to msb (last). the clock signal generated on spiclk is derived from the internal periph_clk signal. periph_clk always operates at the frequency, f osc , and runs constantly except when stopped in mcu power down mode. spiclk is a result of di- viding periph_clk by a sum of different divisors selected by the value contained in the spiclkd register. the default value in spiclkd after a re- set divides periph_clk by a factor of 4. the bits in spiclkd can be set to provide resulting divisor values in of sums of multiples of 4, such as 4, 8, 12, 16, 20, all the way up to 252. for example, if spiclkd contains 0x24, spiclk has the fre- quency of perih_clk divided by 36 decimal. the spiclk frequency must be set low enough to allow the mcu time to read received data bytes without loosing data. this is dependent upon many things, including the crystal frequency of the mcu and the efficiency of the spi firmware. dynamic control at runtime, bits in re gisters spicon0, spicon1, and spistat are managed by firmware for dy- namic control over the spi interface. the bits transmitter enable (te) and receiver enable (re) when set will allow tr ansmitting and receiving respectively. if te is di sabled, both transmitting and receiving are disabled because spiclk is driven to constant output logic ?0? (when spo = 0) or logic '1' (when spo = 1). when the ssel bit is set, the spisel pin will drive to logic '0' (active) to select a connected slave de- vice at the appropriate time before the first data bit of a byte is transmitte d, and spisel will automat- ically return to logic '1' (inactive) after transmitting the eight bit of data, as shown in figure 47., page 117 . spisel will continue to automati- cally toggle this way for each byte data transmis- sion while the ssel bit is set by firmware. when the ssel bit is cleared, the spisel pin will drive to constant logic '1' and stay that way (after a transmission in pr ogress completes). the interrupt enable bits (teie, rorie,tie, and rie) when set, will allow an spi interrupt to be generated to the mcu upon the occurrence of the condition enabled by these bits. firmware must read the four corresponding flags in the spistat register to determine the specific cause of inter- rupt. these flags are automatically cleared when firmware reads the spistat register.
upsd34xx - spi (synchronous peripheral interface) 120/264 table 63. spicon0: control register 0 (sfr d6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? te re spien ssel flsb sbo ? details bit symbol r/w definition 7 ? ? reserved 6terw transmitter enable 0 = transmitter is disabled 1 = transmitter is enabled 5rerw receiver enable 0 = receiver is disabled 1 = receiver is enabled 4 spien rw spi enable 0 = entire spi interface is disabled 1 = entire spi interface is enabled 3 ssel rw slave selection 0 = spisel output pin is constant logic '1' (slave device not selected) 1 = spisel output pin is logic '0' (slave device is selected) during data transfers 2flsbrw first lsb 0 = transfer the most signi ficant bit (msb) first 1 = transfer the least significant bit (lsb) first 1spo? sampling polarity 0 = sample transfer data at the falling edge of clock (spiclk is '0' when idle) 1 = sample transfer data at the risi ng edge of clock (spiclk is '1' when idle) 0 ? ? reserved
121/264 upsd34xx - spi (synchronous peripheral interface) table 64. spicon1: spi interface control register 1 (sfr d7h, reset value 00h) table 65. spiclkd: spi prescaler (clock divide r) register (sfr d2h, reset value 04h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ????teierorietierie details bit symbol r/w definition 7-4 ? ? reserved 3teierw transmission end interrupt enable 0 = disable interrupt for transmission end 1 = enable interrupt for transmission end 2rorierw receive overrun interrupt enable 0 = disable interrupt for receive overrun 1 = enable interrupt for receive overrun 1tierw transmission interrupt enable 0 = disable interrupt for spitdr empty 1 = enable interrupt for spitdr empty 0rierw reception interrupt enable 0 = disable interrupt for spirdr full 1 = enable interrupt for spirdr full bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 div128 div64 div32 div16 div8 div4 ? ? details bit symbol r/w definition 7 div128 rw 0 = no division 1 = divide f osc clock by 128 6div64rw 0 = no division 1 = divide f osc clock by 64 5div32rw 0 = no division 1 = divide f osc clock by 32 4div16rw 0 = no division 1 = divide f osc clock by 16 3div8rw 0 = no division 1 = divide f osc clock by 8 2div4rw 0 = no division 1 = divide f osc clock by 4 1-0 not used ?
upsd34xx - spi (synchronous peripheral interface) 122/264 table 66. spistat: spi interface status register (sfr d3h, reset value 02h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? busy teisf rorisf tisf risf details bit symbol r/w definition 7-5 ? ? reserved 4busyr spi busy 0 = transmit or receive is completed 1 = transmit or receive is in process 3teisfr transmission end interrupt source flag 0 = automatically resets to '0' when firmware reads this register 1 = automatically sets to '1' when transmission end occurs 2rorisfr receive overrun interrupt source flag 0 = automatically resets to '0' when firmware reads this register 1 = automatically sets to '1' when receive overrun occurs 1tisfr transfer interrupt source flag 0 = automatically resets to '0' when spitdr is full (just after the spitdr is written) 1 = automatically sets to '1' when spi tdr is empty (just after byte loads from spitdr into spi shift register) 0risfr receive interrupt source flag 0 = automatically resets to '0' when spirdr is empty (after the spirdr is read) 1 = automatically sets to '1' when spirdr is full
123/264 upsd34xx - usb interface usb interface upsd34xx devices provide a full speed usb (uni- versal serial bus) device interface. the serial in- terface engine (sie) provides the interface between the cpu and the usb (see figure 49. ). notes: 1. for a list of known limit ations of usb interface for upsd34xx devices, please refer to impor- tant notes, page 262 . 2. please make sure you have the latest 3400 usb firmware. the usb module supports the following features: usb 2.0 compliant to full-speed mode (12 mbps) 3.3v usb transceiver five endpoints including control endpoint 0 ? each endpoint includes two 64 byte fifos, one for in and one for out transactions ? endpoints 1 through 4 support interrupt and bulk transfers usb bus suspend detection and resume generation pll multiplier to generate the 48 mhz as required for usb support. interrupts for various usb bus conditions. performs nrzi encoding and decoding, bit stuffing, crc generation and checking, and serial/parallel data conversion double buffering (using fifo pairing) for efficient data transfer in bulk transfer busy bit-based fifo status monitoring fifos accessible via xdata space the analog front-end of the usb module is an on- chip usb transceiver. it is designed to allow volt- age levels equal to v dd from the standard logic to interface with the physical layer of the usb. it is capable of receiving and transmitting serial data at full speed (12 mb/s). the sie is the digital-front-end of the usb block. this module recovers the 12mhz clock, detects the usb sync word, and handles all low-level usb protocols and error checking. the bit-clock recov- ery circuit recovers the clock from the incoming usb data stream and is able to track jitter and fre- quency drift according to the usb specifications. the sie also translates the electrical usb signals into bytes or signals. when there is a usb device address match, the usb data is directed to an endpoint?s fifo for out transactions and read from an endpoint?s fifo for in transactions. con- trol transfers are supported on endpoint0 and in- terrupt and bulk data transfers are supported on endpoints1 through 4. the device?s usb address and the enabling of the endpoints are programma- ble using the sie?s sfrs. important note: the usb sie requires a 48mhz clock to operate properly. a pll is included in the upsd34xx that must be programmed appropriate- ly based on the input clock to provide a 48mhz clock to the sie (see usb_clk, page 47 to set up the pll).
upsd34xx - usb interface 124/264 figure 49. usb module block diagram basic usb concepts the universal serial bus (usb) is more complex than the standard serial po rt and requires familiar- ity with the specification to fully understand how to use the usb peripheral in the upsd34xx. the usb specification is available on the internet at http://www.usb.org. some basic concepts will be presented in this section but knowledge of the usb specification is required. in a usb system, there is only one master and the master is the host computer. the host controls all activity on the bus and devices respond to re- quests from the host. the only exception is when a device has been put into a low power suspend mode by the host. in this case, the device can sig- nal a remote wakeup. outside of that exception, all activity is controlled and initiated by the host. the host-centric model versus a peer-to-peer model provides the best way to develop low cost periph- erals by keeping the complex control logic on the host side. the upsd34xx is a peripheral (non- host) device. communication flow. the usb provides a means for communication between host (client) software and a function on a usb device. func- tions can have different requirements for the com- munication flow depending on the client software to the usb function interaction. with usb, the var- ious communication flows are separated to pro- vide better bus utilization. for example, one communication flow is used for managing the de- vice while another is for tr ansferring data related to the operation of the device. some bus access is used for each communication flow with each flow terminated at an endpoint on a device. each end- point has various aspects associated with the communication flow. a usb device looks like a collection of endpoints to the usb system. 8032 mcu usb sfrs usb transceiver serial interface engine pll clock ctrl and data ctrl and data ctrl ctrl x data d? d+ usb? usb+ s f r b u s ai10488 endpoint4 3 - 40mhz 48mhz endpoint0 endpoint4 endpoint0 in fifos (64 bytes each) out fifos (64 bytes each) setup command buffer (8 bytes) fifo interface logic
125/264 upsd34xx - usb interface endpoints. each usb device contains a collec- tion of independent endpoints, with an endpoint being the destination of a communication flow be- tween client software and the device. by design, each usb device?s endpoints are given specific unique identifiers called endpoint numbers. in ad- dition, each endpoint has an associated direction for the data flow, either in (from device to host) or out (from host to device). at the time a device is connected to the usb, it is assigned a unique ad- dress. the combination of the device address, endpoint number, and direction allows each end- point to be uniquely referenced. each endpoint has some associated characteris- tics for the communication flow with the client soft- ware running on the host. those characteristics include: endpoint number; frequency and latency requirements; bandwidth requirements; maximum packet size capability; error handling requirements; data transfer direction; and transfer type. all usb devices are required to implement a de- fault control method that uses both the input and output endpoints with endpoint zero. the usb system software uses this default control method to initialize and generically manipulate the logical device as the default control pipe. endpoint zero is always accessible and provides access to the device?s configuration and status information as well as some basic control access. additional (non-zero) endpoints provide the com- munication flow required for the functionality of the device. the non-zero endpoints are available for use only after the device is configured per the nor- mal device configuration process (see chapter 9 of the usb specification, http://www.usb.org ).
upsd34xx - usb interface 126/264 packets. usb transactions consist of data pack- ets that contain special codes called packet ids (pids). a pid signifies the kind of packet that is being transmitted. while there are more types of pids in a usb system, th e upsd34xx responds to the three types shown in table 67. table 67. types of packet ids figure 50. shows an example of packets sent dur- ing a usb transfer. the first packet is a token packet with an out pid. the out pid indicates that the host is going to send data to the ad- dressed device?s endpoint. the addr field con- tains the address of the device and the endp field contains the endpoint within the addressed de- vice. the crc5 is a cyclic redundancy check for error checking. the data packet contains a data1 or data0 pid. in a usb system, the host or device that is sending data is responsible for toggling the data pid be- tween data0 and data1. the receiving device keeps track of the toggle bit and compares it with the data pid that is received. this provides a means for the receiving host or device to detect a corrupted handshake packet. the payload data is the data that the host is sending to the device and the crc16 is used for error checking. for an out transaction, the host sends the token and data packets. the receiving device sends a handshake packet to notify the host whether it was able to accept the packet or not. there are three handshake pids as follows: ? ack: this pid indicates that the device received the data successfully. ? nak: this handshake indicates that the device was not able to receive the data (it is busy). a nak does not mean there was an error, since errors are indicated by a ?no handshake? packet. when the host receives a nak pid or does not receive a handshake packet at all, the host retries sending the data at a later time. ? stall: this handshake indicates that something is wrong. for example, the host has sent a device request that is not understood, the host is trying to access a resource that is not available, or something is wrong with the device. figure 50. usb packets in a usb transfer example pid type pid name token in, out, setup data data0, data1 handshake ack, nak, stall token packet data packet handshake packet out addr endp crc5 crc16 ack data1 payload data 12 3 token packet data packet handshake packet out addr endp crc5 crc16 ack data0 payload data 45 6 ai10489
127/264 upsd34xx - usb interface data transfers with the host. the host issues out tokens followed by data tokens to send data to a device. the device responds with an appropri- ate handshake packet (ack/nak), indicating whether it was able to receive the data. if the de- vice does not receive the data packet ok (be- cause there is some error), it does not respond with a handshake packet. in the case of a nak or no response, the host retries sending the data at a later time. usb devices are not able to send data to a host whenever they have it ready. when a device has data ready, it loads data into its endpoint buffer, making it ready for a tran sfer. the data will remain in the buffer until the host issues an in token to that device?s endpoint, at which time the data will be sent. if the host receives the data ok, it follows with an ack handshake (a host never naks). if the host did not receive the data ok, there is no handshake packet. in this case, the device should reload its endpoint buffer as appropriate and the host will retry again later to retrieve the data. types of transfers the usb specification defines four types of trans- fers, bulk, interrupt, isochronous, and control. note: the upsd34xx supports all types of trans- fers except isochronous. bulk transfers (see figure 51. ) bulk data is transferred in both directions and is used with both in and out endpoints. packets may be 8, 16, 32, or 64 bytes in length. bulk transfers occur in bursts, and are scheduled by the host when there is available time on the bus. while there is no guaranteed delivery time for bulk transfers, the accuracy of the data is guaranteed due to automatic retries for erroneous data. bulk transfers are typically used for mass storage, printer, and scanner data. interrupt transfers (see figure 52. ) interrupt data is a lot like bulk data but travels only in one direction, from the device to the host, so only in endpoints are used. interrupt data holds packet sizes ranging from 1 to 64 bytes. interrupt endpoints have an associated polling interval, meaning that the host sends in tokens at a periodic interval to the host on a regular basis. interrupt transfers are typically used for human interfac e devices such as keyboards, mice, and joysticks. figure 51. in and out bulk transfers figure 52. interrupt transfer token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data token packet data packet handshake packet out addr endp crc5 crc16 ack data1 payload data ai10490 token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data ai10491
upsd34xx - usb interface 128/264 control transfers (see figure 53. ) control transfers are used to configure and send commands to a device. control transfers consist of two or three stages: ? setup this stage always consists of a data packet with eight bytes of usb control data. ? data stage (optional) if the control data is such that the host is requesting information from the device, the setup stage is followed by a data stage. in this case, the host sends an in token and the device responds with the requested data in the data packet. ? status stage this stage is essentially a handshake informing the device of a successfully completed control operation. enumeration. enumeration is the process that takes place when a device is first connected to the usb. during enumeration, the host requests infor- mation from the device about what it is, how many endpoints it has, the power requirements, bus bandwidth requirements, and what driver to load. once the enumeration process is complete, the device is available for use. the enumeration process consists of a series of six steps as follows: 1. when a device is first connected to the usb, its address is zero. upon detecting a new device connected to the usb, the host sends a get_descriptor request to address zero, endpoint0. 2. the device, upon receiving a get_descriptor request, sends data back to the host identifying what it is. 3. the host resets the device and then sends a set_address request. this is a unique address that identifies it from all other devices connected to the usb. this address remains in effect until the device is disconnected from the usb. 4. the host sends more get_descriptor requests to the device to gather more detailed information about it and then loads the specified driver. 5. the host will setup and enable the endpoints defined by the device. 6. the device is now configured and ready for use with the host communicating to the device using the assigned address and endpoints. figure 53. control transfer token packet data packet handshake packet setup addr endp crc5 crc16 setup stage data stage (optional) status stage ack data0 payload data (8 bytes) token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data token packet data packet handshake packet out addr endp crc5 crc16 ack data1 ai10492
129/264 upsd34xx - usb interface endpoint fifos the upsd34xx?s usb module includes 5 end- points and 10 fifos. each endpoint has two fifos with one for in and the other for out trans- actions. each fifo is 64 bytes long and is selec- tively made visible in a 64-byte xdata segment for cpu access. for efficient data transfers, the fifos may be paired for double buffering. with double buffering, the cpu may operate on the contents in one buffer while the sie is transmitting or receiving data in the paired buffer. upsd34xx supported endpoints and fifos are shown in ta- ble 68. busy bit (bsy) operation. each fifo has a busy bit (bsy) that indicates when the usb sie has ownership of the fifo. when the sie has ownership of the fifo, it is either writing data to or reading data from the fifo. the sie writes data to the fifo when it is receiving an out packet and reads data from the fifo when it is sending data in response to an in packet. the cpu is only per- mitted to access the fifo when it is not busy and accesses to it while busy are ignored. once the in fifo has been written with data by the cpu, the cpu updates the usize register with the number of bytes written to the fifo. the value written to the usize register tells the sie the number of bytes to send to the host in response to an in packet. once the usize register is written, the fifos busy bit is set and remains set until the data has been transmitted in response to an in packet. the busy bit for an out fifo is set as soon as the sie starts receiving an out packet from the host. once all the data has been received and written to the fifo, the sie clears the busy bit and writes the number of bytes received to the usize register. busy bit and interrupts. when the fifo?s inter- rupt is enabled, a transition of the busy bit from a '1' to a '0' (when ownership of the fifo changes from the sie to the cpu) generates a usb inter- rupt with the corresponding flag set. for an inter- rupt on an in fifo, the cpu must fill the fifo with the next set of data to be sent and then update the usize register with the number of bytes to send. for an interrupt on an out fifo, the cpu reads the usize register to determine the number of bytes received and then reads that number of data bytes out of the fifo. table 68. upsd34xx supported endpoints endpoint function max packet size (fifo size) supported directions 0 control 64 bytes out 0 control 64 bytes in 1 bulk/interrupt out 64 bytes out 1 bulk/interrupt in 64 bytes in 2 bulk/interrupt out 64 bytes out 2 bulk/interrupt in 64 bytes in 3 bulk/interrupt out 64 bytes out 3 bulk/interrupt in 64 bytes in 4 bulk/interrupt out 64 bytes out 4 bulk/interrupt in 64 bytes in
upsd34xx - usb interface 130/264 fifo pairing. the fifos on endpoints 1 through 4 may be used independently as shown in figure 54. as fifos with no pairing or they may be selec- tively paired to provide double buffering (see fig- ure 55., page 131 ). double buffering provides an efficient way to optimize data transfer rates with bulk transfers. double buffering allows the cpu to process a data packet for an endpoint while the sie is receiving or transmitting another packet of data on the same endpoint and direction. fifo pairing is controlled by the usb pairing control register (see upair, table 71., page 135 ). fifo pairing options are listed below: in fifo 1 and 2 out fifo 1 and 2 in fifo 3 and 4 out fifo 3 and 4 note: when the fifos are paired, the cpu must access the odd numbered fifo while the even numbered fifos are no longer available for use. also when they are paired, the active fifo is au- tomatically toggled by the update of usize. ? non-pairing fifos example consider a case wher e the device needs to send 1024 bytes of data to the host. without fifo pairing (see figure 54. ), the cpu loads the in endpoint0 fifo with 64 bytes of data and waits until the host sends an in token to endpoint0, and the sie transfers the data to the host. once all 64 bytes have been transferred by the sie, the fifo becomes empty and the cpu starts writing the next 64 bytes of data to the fifo. while the cpu is writing the data to the fifo, the host is sending in tokens to endpoint0, requesting the next 64 bytes of data, but only gets naks while the fifo is being loaded. once the fifo has been loaded by the cpu, the sie starts sending the data to the host with the next in endpoint0 token. again, the cpu waits until the sie transfers the 64 bytes of data to the host. this is repeated until all 1024 bytes have been transferred. figure 54. fifos with no pairing 8032 mcu usb sfrs serial interface engine ctrl x data s f r b u s ai10493 endpoint4 in fifo endpoint3 in fifo endpoint2 in fifo endpoint1 in fifo endpoint0 in fifo endpoint0 out fifo endpoint1 out fifo endpoint2 out fifo endpoint3 out fifo endpoint4 out fifo fifo interface logic endpoint4 endpoint3 endpoint2 endpoint1 endpoint0 endpoint0 endpoint1 endpoint2 endpoint3 endpoint4
131/264 upsd34xx - usb interface ? pairing fifos example now assume that in endpoint1 and endpoint2 fifos are paired for double buffering and the same 1024 bytes of data are to be transferred to the host. as in the non-pairing example, the cpu loads the in endpoint0 fifo with 64 bytes of data. instead of having to wait for the sie to transfer the 64 bytes of data to the host, the cpu can write another 64 bytes of data to in endpoint0 fifo. wh ile the cpu is writing the second packet of 64 bytes of data into the fifo, the sie is sending the first packet of 64 bytes of data to the host. after the cpu has written the second packet of 64 bytes to the fifo, it waits a shorter amount of time for the sie to complete sending the first packet of data since they were work ing concurrently. as soon as the first packet is sent by the sie, the second packet is immediately available to be sent by the sie since the fifo was already loaded by the mcu. also, after the first packet is sent by the sie, the alternate fifo is available for the mcu to load the third packet of 64 bytes of data. with double buffering, the mcu is able to always have a fifo loaded and ready with data to be sent by the sie when the host sends an in token maximizing the data transfer rate. figure 55. fifo pairing example (1/2 in paired and 3/4 out paired) 8032 mcu usb sfrs serial interface engine ctrl x data s f r b u s ai10494 endpoint4 in fifo endpoint3 in fifo endpoint2 in fifo p a i r e d p a i r e d endpoint1 in fifo endpoint0 in fifo endpoint0 out fifo endpoint1 out fifo endpoint2 out fifo fifo interface logic endpoint4 endpoint3 endpoint2 (not available) endpoint2 (not available) endpoint1 endpoint0 endpoint4 endpoint3 endpoint1 endpoint0 endpoint0 endpoint1 endpoint2 endpoint3 endpoint0 endpoint1 endpoint2 endpoint3 endpoint4 (not available) endpoint4 (not available) endpoint3 out fifo p a i r e d p a i r e d endpoint4 out fifo
upsd34xx - usb interface 132/264 reading and writing fifos. there are a total of ten 64-byte fifos. each of the five endpoints has two fifos, one in fifo for in transactions and one out fifo for out tr ansactions. the fifos are accessible by the cpu through a 64-byte seg- ment in the xdata space when the visible bit is set (see table 80., page 143 ). if the visible bit is not set, the fifos are not accessible by the cpu but are still accessible by the sie. the base ad- dress of the 64-byte segment is specified by the usb base address high register (see table 85., page 148 ) and the usb base address low register (see table 86., page 148 ). when the visible bit is set, the fi fo that is accessible in the 64-byte xdata space segment is the fifo selected by the usel register. the usel register contains two fields used for selecting the accessi- ble fifo. the ep field determines the endpoint selected and the dir bit selects the in or out fifo associated with the endpoint. accessing fifo control registers, ucon, and usize. each of the 10 endpoint fifos has an as- sociated usb endpoint control register (ucon, 0f1h) and a usb fifo valid size register (usize, 0f2h). the usb endpoint select regis- ter (usel) is not only used to select the endpoint fifo that is accessible in the xdata space, but also selects the associated endpoint?s ucon and usize registers that are accessible at sfr ad- dresses 0f1h and 0f2h. accessing the setup command buffer. setup packets are sent from the host to a device?s endpoint0 and consist of 8 bytes of command da- ta. when the sie receives a setup packet from the host, it stores the 8 bytes of data in the command buffer. the command buffer is accessed via the indexed usb setup command value register (us- cv). the usb setup command index register (usci) is used to select the byte from the com- mand buffer that is read when accessing the uscv register. usb registers the usb module is controlled via registers mapped into the sfr space. the usb sfrs con- sist of the following: ? uaddr: usb device address ? upair: usb fifo pairing control ? uie0~3: usb interrupt enable ? uif0~3: usb interrupt flags ? uctl: usb control ? usta: usb status ? usel: usb endpoint and direction select ? ucon: usb selected fi fo control register ? usize: usb selected fifo size register ? ubase: usb base address register ? usci: usb setup command index ? uscv: usb setup command value the memory map for the usb sfrs, the individual bit names, and the reset values are shown in ta- ble 69., page 133 .
133/264 upsd34xx - usb interface table 69. upsd34xx usb sfr register map sfr addr (hex) sfr name bit name and reset value (hex) comment 76 5 4 3 2 1 0 e2 uaddr ? usbaddr[6:0] 00 usb address e3 upair ? ? ? ? pr3out pr1out pr3in pr1in 00 usb pairing control e4 uie0 ? ? ? ? rstie suspndie eopie resumie 00 usb global interrupt enable e5 uie1 ? ? ? in4ie in3ie in2ie in1ie in0ie 00 usb in fifo interrupt enable e6 uie2 ? ? ? out4ie out3ie out2ie out1ie out0ie 00 usb out fifo interrupt enable e7 uie3 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0ie 00 usb in fifo nak int. enable e8 uif0 glf inf outf nakf rstf suspndf eopf resumf 00 usb global interrupt flag e9 uif1 ? ? ? in4f in3f in2f in1f in0f 00 usb in fifo interrupt flag ea uif2 ? ? ? out4f out3f out2f out1f out0f 00 usb out fifo interrupt flag eb uif3 ? ? ? nak4f nak3f nak2f nak1f nak0f 00 usb in fifo nak int. flag ec uctl ? ? ? ? ? usben visible wakeup 00 usb control ed usta ? ? ? ? rcvt setup in out 00 usb status ee reserved ef usel dir ? ? ? ? ep[2:0] 00 usb endpoint select f1 ucon ? ? ? ? enable stall toggle bsy 00 usb endpoint control
upsd34xx - usb interface 134/264 note: note: bits marked with a ??? are reserved. f2 usize ? size[6:0] 00 usb fifo valid size f3 ubaseh baseaddr[15:8] 00 usb base address high f4 ubasel baseaddr[7:6] 0 0 0 0 0 0 00 usb base address low f5 usci ? ? ? ? ? usci[2:0] 00 usb setup command index f6 uscv uscv[7:0] 00 usb setup command value sfr addr (hex) sfr name bit name and reset value (hex) comment 76 5 4 3 2 1 0
135/264 upsd34xx - usb interface usb device address register. initially when a device is connected to the usb, it responds to the host on address 0. using the set_address re- quest, the host assigns a unique address to the device. the firmware writes this address to the usb device address register (see table 70. ), and subsequently the sie only responds to transac- tions on that assigned address. this assigned ad- dress is in effect until the device or an upstream hub is disconnected from the usb, the host issues a usb reset, or the host shuts down. the address register is cleared with a hardware reset or a usb reset. endpoint fifo pairing. endpoint fifos can be paired for double buffering to provide an efficient method for bulk data transfers. with double buffer- ing enabled, the mcu can operate on one data packet while another is being transferred over usb. when two fifos are paired, the active fifo is au- tomatically toggled by the update of usize. the mcu must only use the odd numbered endpoint fifo when paired in order to access the active fifo. for example, if endpoints 3 and 4 out fifos are paired, the active fifo is accessed via endpoint 3?s out fifo (see table 71. ). table 70. usb device address register (uaddr 0e2h, reset value 00h) table 71. pairing control register (upair 0e3h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? usbaddr[6:0] details bit symbol r/w definition 7 ? ? reserved 6:0 usbaddr r/w usb address of the device. these bits are cleared with a hardware reset or a usb reset. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? pr3out pr1out pr3in pr1in details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3pr3outr/w setting this bit enables double buffering of the out fifos for endpoints 3 and 4. access to the double buffered fifos is through endpoint3?s out fifo. 2pr1outr/w setting this bit enables double buffering of the out fifos for endpoints 1 and 2. access to the double buffered fifos is through endpoint1?s out fifo. 1pr3inr/w setting this bit enables double buffer ing of the in fifos for endpoints 3 and 4. access to the double buff ered fifos is through endpoint3?s in fifo. 0pr1inr/w setting this bit enables double buffer ing of the in fifos for endpoints 1 and 2. access to the double buff ered fifos is through endpoint1?s in fifo.
upsd34xx - usb interface 136/264 usb interrupts. there are many usb related events that generate an interrupt. the events that generate an interrupt are selectively enabled through the use of the usb interrupt enable reg- isters. all usb interrupts are serviced through a single interrupt vector (see interrupt system, page 41 for the address of the interrupt vector). when a usb interrupt occurs, firmware must check the usb interrupt flag registers to determine the source of the interrupt, clear that in- terrupt flag and process the interrupt before return- ing to the interrupted code. the usb interrupt priority can be set to low or high. for the best usb response time and to max- imize data transfer times, the usb interrupt should be set to the highest priority (see the interrupt system for the details on setting the interrupt pri- ority). ? usb reset interrupt the host signals a bus reset by driving both d+ and d? low for at least 10ms. when the upsd34xx?s sie detects a reset on the usb, it generates the rst interrupt request. when a usb reset is detected, the usb sie is reset. a usb reset does not reset the cpu. ? usb suspend interrupt if the upsd34xx?s sie detects 3ms of no activity on the bus, it generates the suspend interrupt request. it also causes the clock to the sie to shut down to conserve power. the clock to the sie is turned back on when a usb resume signal or reset is detected. ? usb eop (end of packet) interrupt every packet sent on the usb includes a signal, called eop, to indicate the end of the packet. when an eop is detected, the sie generates an eop interrupt. ? usb resume interrupt when usb activity is detected and the sie is in the suspend state, a resume interrupt is generated and the usb clock to the sie is turned back on. ? usb global interrupt enable register (uie0) there are four usb events that are considered to be global in nature, meaning they are not specific to an endpoint, but apply to the usb bus in general. the four global usb events include reset, suspend, eop, and resume. each event can be enabled to generate an interrupt using the uie0 register shown in table 72. table 72. usb global interrupt enable register (uie0 0e4h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? rstie suspendie eopie resumie details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 rstie r/w enable the usb reset interrupt 2 suspendie r/w enable the usb suspend interrupt 1 eopie r/w enable the usb eop interrupt 0 resumie r/w enable the usb resume interrupt
137/264 upsd34xx - usb interface ? usb in fifo interrupt enable register (uie1) when an endpoint?s in fifo has been successfully sent to the host with an in transaction, the fifo becomes empty. the uie1 register is used to enable each endpoint?s in fifo interrupt ( table 73. ). ? usb out fifo interrupt enable register (uie1) when an endpoint?s out fifo has been filled by an out transaction from the host, the fifo becomes full. the uie2 register is used to enable each endpoint?s out fifo interrupt ( table 74. ). table 73. usb in fifo interrupt enable register (uie1 0e5h, reset value 00h) table 74. usb out fifo interrupt enable register (uie2 0e6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? in4ie in3ie in2ie in1ie in0ie details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 in4ie r/w enable endpoint 4 in fifo interrupt 3 in3ie r/w enable endpoint 3 in fifo interrupt 2 in2ie r/w enable endpoint 2 in fifo interrupt 1 in1ie r/w enable endpoint 1 in fifo interrupt 0 in0ie r/w enable endpoint 0 in fifo interrupt bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? out4ie out3ie out2ie out1ie out0ie details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 out4ie r/w enable endpoint 4 out fifo interrupt 3 out3ie r/w enable endpoint 3 out fifo interrupt 2 out2ie r/w enable endpoint 2 out fifo interrupt 1 out1ie r/w enable endpoint 1 out fifo interrupt 0 out0ie r/w enable endpoint 0 out fifo interrupt
upsd34xx - usb interface 138/264 ? usb in fifo nak interr upt enable register (uie3) when an endpoint?s in fifo is empty and an in transaction to that endpoint has been received, the sie sends a nak handshake token since there is no data ready for it to send. the uie3 register (see table 75. ) is used to enable each endpoint?s in fifo nak interrupt. table 75. usb in fifo nak interrupt enable register (uie3 0e7h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0ie details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 nak4ie r/w enable endpoint 4 in fifo nak interrupt 3 nak3ie r/w enable endpoint 3 in fifo nak interrupt 2 nak2ie r/w enable endpoint 2 in fifo nak interrupt 1 nak1ie r/w enable endpoint 1 in fifo nak interrupt 0 nak0ie r/w enable endpoint 0 in fifo nak interrupt
139/264 upsd34xx - usb interface ? usb global interrupt flag register (uif0) there are many different events that generate a usb interrupt requiring a number of registers to indicate the cause of the interrupt. to more efficiently identify the cause of the interrupt, the usb global interrupt flag register (see table 76. ) indicates the type of interrupt that occurred. once the type of interrupt is identified, the associated interrupt flag register may be read to determine the exact cause of the interrupt. table 76. usb global interrupt flag register (uif0 0e8h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 glf inf outf nakf rstf suspendf eopf resumf details bit symbol r/w definition 7glfr global interrupt flag logical or of the rstf, suspendf, eopf, and resumf interrupt flags 6infr in fifo interrupt flag logical or of the in4f, in3f, in2f, in1f, and in0f interrupt flags 5outfr out fifo interrupt flag logical or of the out4f, out3f, out2f, out1f, and out0f interrupt flags 4nakfr nak fifo interrupt flag logical or of the nak4f, nak3f, nak2f, nak1f, and nak0f interrupt flags 3rstfr/w usb reset flag this bit is set when a usb reset is detected on the d+ and d- lines. when a usb reset is detected, the usb module is reset. note: the cpu is not reset with a usb reset. 2 suspendf r/w usb suspend mode flag this bit is set when the sie detects 3ms of no activity on the bus and the clock to the sie is also shut down to conserve power. 1eopfr/w end of packet flag this bit is set when a valid end of packet sequence is detected on the d+ and d? line. 0 resumef r/w resume flag this bit is set when usb bus activi ty is detected while the suspndf bit is set.
upsd34xx - usb interface 140/264 ? usb in fifo interrupt flag (uif1) the usb in fifo interrupt flag register (see table 77. ) contains flags that indicate when an in endpoint fifo that was full becomes empty. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 77. usb in fifo interrupt flag (uif1 0e9h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? in4f in3f in2f in1f in0f details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4in4fr/w endpoint 4 in fifo interrupt flag this bit is set when the fifo st atus changes from full to empty. 3in3fr/w endpoint 3 in fifo interrupt flag this bit is set when the fifo st atus changes from full to empty. 2in2fr/w endpoint 2 in fifo interrupt flag this bit is set when the fifo st atus changes from full to empty. 1in1fr/w endpoint 1 in fifo interrupt flag this bit is set when the fifo st atus changes from full to empty. 0in0fr/w endpoint 0 in fifo interrupt flag this bit is set when the fifo st atus changes from full to empty.
141/264 upsd34xx - usb interface ? usb out fifo interrupt flag (uif2) the usb out fifo interrupt flag register (see table 78. ) contains flags that indicate when an out endpoint fifo that was empty becomes full. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 78. usb out fifo interrupt flag (uif2 0eah, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? out4f out3f out2f out1f out0f details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 out4f r/w endpoint 4 out fifo interrupt flag this bit is set when the fifo st atus changes from empty to full. 3 out3f r/w endpoint 3 out fifo interrupt flag this bit is set when the fifo st atus changes from empty to full. 2 out2f r/w endpoint 2 out fifo interrupt flag this bit is set when the fifo st atus changes from empty to full. 1 out1f r/w endpoint 1 out fifo interrupt flag this bit is set when the fifo st atus changes from empty to full. 0 out0f r/w endpoint 0 out fifo interrupt flag this bit is set when the fifo st atus changes from empty to full.
upsd34xx - usb interface 142/264 ? usb in fifo nak interrupt flag (uif3) the usb in fifo nak interrupt flag register (see table 79. ) contains flags that indicate when an in endpoint fifo is not ready. the endpoint fifo is not ready when data has not been loaded into its fifo and the usize register has not been written to (writing to the usize register puts the fifo in a ?ready? to send data state). until the fifo is ready, the sie will continue to nak all in requests to the respective endpoint. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 79. usb in fifo nak interrupt flag (uif3 0ebh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? nak4f nak3f nak2f nak1f nak0f details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 nak4f r/w endpoint 4 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 3 nak3f r/w endpoint 3 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 2 nak2f r/w endpoint 2 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 1 nak1f r/w endpoint 1 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 0 nak0f r/w endpoint 0 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready.
143/264 upsd34xx - usb interface ? usb control register (uctl) the usb control register (see table 80. ) is used to enable the sie, make the endpoint fifos visible in the xdata space and for generating a remote wakeup signal. upon a reset, the usb module is disabled and must be enabled by the cpu for communication with the host over the usb. table 80. usb control register (uctl 0ech, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? ? usben visible wakeup details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 ? ? reserved 2 usben r/w usb enable when this bit is set, the usb functi on is enabled and the sie responds to tokens from the host. 1visibler/w usb fifo visible when this bit is set, the selected usb fifo is accessible (visible) in the xdata space. 0 wakeup r/w remote wakeup enable this bit forces a resume or ?k? state on the usb data lines to initiate a remote wake-up. the cpu is responsible for controlling the timing of the forced resume that must be between 10m s and 15ms. setting this bit will not cause the resumf bit to be set.
upsd34xx - usb interface 144/264 ? usb endpoint0 st atus (usta) the usb endpoint0 status register (see table 81. ) provides the status for events that occur on the usb that are directed to endpoint0. table 81. usb endpoint0 status (usta 0edh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? rcvt setup in out details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 rcvt r received data toggle bit this bit indicates the toggle bit of the received data packet: 0 = data0, and 1 = data1 2 setup r/w setup token detect bit this bit is set when endpoint0 receives a setup token. this bit is not cleared when endpoint0 receives an in or out token following the setup token that set this bit. this bit is cleared by software or a reset. 1inr in token detect bit this bit is set when endpoint0 receives an in token. this bit is cleared when endpoint0 receives a setup or out token. 0outr out token detect bit this bit is set when endpoint0 receives an out token. this bit is cleared when endpoint0 receives a setup or in token.
145/264 upsd34xx - usb interface ? usb endpoint select register (usel) endpoints share the same xdata space for fifos as well as the same sfr addresses for control and fifo valid size registers. the usb endpoint select register (see table 82. ) is used to select the desired direction and endpoint that is accessed when reading or writing to the fifo xdata address space. this register is also used to select the direction and endpoint when accessing the usb endpoint control register. table 82. usb endpoint select regi ster (usel 0efh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 dir ? ? ? ? ep[2] ep[1] ep[0] details bit symbol r/w definition 7dirr/w fifo?s direction select bit: 0: in fifo select 1: out fifo select 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 ? ? reserved 2:0 ep r/w endpoint selects bits: 0: endpoint0 1: endpoint1 2: endpoint2 3: endpoint3 4: endpoint4
upsd34xx - usb interface 146/264 ? usb endpoint control register (ucon) the endpoint selected by the usb endpoint select register (see table 82., page 145 ) determines the direction and fifo (in or out) that is controlled by the usb endpoint control register (see table 83. ). the usb endpoint control register is used to control the selected endpoint and provides some status about that endpoint. table 83. usb endpoint control register (ucon 0f1h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? enable stall toggle bsy details bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 enable r/w selected fifo enable bit 2stallr/w stall control bit when this bit is set, the endpoint returns a stall handshake whenever it receives an in or out token. 1 toggle r/w data toggle bit ? endpoint in case the state of this bit determines the type of data packet (0=data0 or 1=data1) that will be sent during t he next in transaction. the cpu is responsible for toggling this bit for every in transaction. ? endpoint out case the state of this bit indicates t he type of data packet pid that was received with the last out transaction (0=data0, 1=data1). the cpu is responsible for comparing this bit with what is expected for error detection and processing. 0 bsy r/w fifo busy status ? endpoint in case once the fifo has been loaded and armed (usize written with the number of bytes to send), the bsy bit is set and remains set until the sie has transmitted the data in the fifo. the cpu should only access the fifo when bsy = 0. ? endpoint out case while the sie is receiving data and stor ing it in the fifo (bsy = 1), it should not be accessed by the cpu. once the out transaction is complete (bsy=0), the cpu may read the contents of the fifo. the bsy bit will remain cleared until another out transaction is received.
147/264 upsd34xx - usb interface ? usb fifo valid size (usize) the endpoint selected by the usb endpoint select register (see table 82., page 145 ) determines the direction and fifo that is controlled by the usb fi fo valid size (see table 84. ). the usb fifo valid size register indicates the number of bytes loaded into the in fifo that the sie is to send in a data packet for an endpoint in case and indicates the number of bytes received for an endpoint out case. table 84. usb fifo valid size (usize 0f2h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? size[6:0] details bit symbol r/w definition 7 ? ? reserved 6:0 size r/w ? endpoint in case the cpu writes the usize register with the number of bytes it loaded into the in endpoint fifo for transmission with the next in transaction. once the usize regi ster has been written, the fifo becomes ready for transmission. ? endpoint out case the cpu reads the usize register to determine how many bytes were received in the data packet during the last out transaction. this tells the cpu how many valid bytes to read from the fifo. note: since the fifos are 64 bytes in length, the maximum value for size is 64 (40h).
upsd34xx - usb interface 148/264 ? usb fifo base address high and low registers (ubaseh and ubasel) all 10 endpoint fifos share the same 64-byte address range. the 16-bit base address for the fifos is specified using the usb base address registers (see table 85. and table 86. ). the usb endpoint select register (see table 82., page 145 ) selects the direction and the endpoint for the fifo that is accessed when addressing the 64-bytes of xdata space starting with the base address specified in the base address registers. the base address is a 64-byte segment where the lower 6 bits of the base register are hardwired to '0.' important note: the usb fifo base address must be set to an open 64-byte segment in the xdata space. care should be taken to ensure that there is no overlap of addresses between the usb fifos and the flash memory, sram, csiop registers, and anything else accessed in the xdata space. while the logic in the psd module handles overlap of flash memory, sram, and the csiop registers with a fixed priority (see psd module functional description, page 165 ), this is not the case with the usb fi fos. unpredictable results as well as potential damage to the device may occur if there is an overlap of addresses. table 85. usb fifo base address high register (ubaseh 0f3h, reset value 00h) table 86. usb fifo base address low re gister (ubasel 0f4h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 baseaddr[15:8] details bit symbol r/w definition 7:0 baseaddr [15:8] r/w the upper 8 bits of the 16-bit base address for usb fifos to be mapped in xdata space bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 baseaddr[7:6] 0 0 0 0 0 0 details bit symbol r/w definition 7:6 baseaddr [7:6] r/w bits 7 and 6 of the 16-bit base addr ess for the usb fifos to be mapped in xdata space 5:0 baseaddr [5:0] r hardwired '0'
149/264 upsd34xx - usb interface ? usb setup command index and value registers (usci and uscv) when a setup/data packet is received over the usb, the 8 bytes of data received are stored in a command buffer. the usb setup command index register (see table 87. ) determines which one of the eight bytes in the buffer is read using the usb setup command value register (see table 88. ). table 87. usb setup command index register (usci 0f5h, reset value 00h) table 88. usb setup command value register (uscv 0f6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? ? usci[2:0] details bit symbol r/w definition 7:3 ? ? reserved 2:0 usci[2:0] r/w index to access one of the 8 bytes of usb setup command data received with the last setup transaction bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 uscv[7:0] details bit symbol r/w definition 7:0 uscv r/w the nth byte of the 8 bytes of usb setup command data received with the last setup transaction. the nth byte that is read from this register is specified by the index val ue in the usci register.
upsd34xx - usb interface 150/264 typical connection to usb connecting the upsd34xx to the usb is simple and straightforward. figure 56. shows a typical self-powered example requiring only three resis- tors and a usb power detection circuit. the usb power detection circuit detects when the device has been connected to the usb. when v bus is de- tected, it switches 3.3v to the pull-up resistor on the d+ line. per the usb specification, the pull-up resistor on d+ is required to signal to the upstream usb port when a full speed device has been con- nected to the bus. the resistors in series in the d+ and d? lines are recommended per the usb spec- ification to reduce transients on the data lines. figure 56. typical self powered example usb power detection block 22 ? v bus v cc d? d+ gnd usb? usb+ gnd v cc v dd v cc v dd 22 ? usb upsd34xx 1.5k ? +3.3v ai10495
151/264 upsd34xx - analog-to-digital convertor (adc) analog-to-digital convertor (adc) the adc unit in the upsd34xx is a sar type adc with an sar register, an auto-zero comparator and three internal dacs. the unit has 8 input channels with 10-bit resolution. the a/d converter has its own v ref input (80-pin package only), which specifies the voltage reference for the a/d operations. the analog to digital converter (a/d) allows conversion of an analog input to a corre- sponding 10-bit digital va lue. the a/d module has eight analog inputs (p1.0 through p1.7) to an 8x1 multiplexor. one adc chann el is selected by the bits in the configuration register. the converter generates a 10-bits result via successive approxi- mation. the analog supply voltage is connected to the v ref input, which powers the resistance lad- der in the a/d module. the a/d module has 3 registers, the control regis- ter acon, the a/d result register adat0, and the second a/d result regist er adat1. the adat0 register stores bits 0.. 7 of the converter output, bits 8.. 9 are stored in bits 0..1 of the adat1 reg- ister. the acon register controls the operation of the a/d converter module. three of the bits in the acon register select the analog channel inputs, and the remaining bits control the converter oper- ation. adc channel pin input is enabled by setting the corresponding bit in the p1sfs0 and p1sfs1 registers to '1' and the channel select bits in the acon register. the adc reference clock (adcclk) is generated from f osc divided by the divider in the adcps register. the adc operates within a range of 2 to 16mhz, with typical adcclk frequency at 8mhz. the conversion time is 4s typical at 8mhz. the processing of conversion starts when the start bit adst is set to '1 .' after one cycle, it is cleared by hardware. the adc is monotonic with no missing codes. measurement is by continuous conversion of the analog input. the adat regis- ter contains the results of the a/d conversion. when conversion is complete, the result is loaded into the adat. the a/d conversion status bit adsf is set to '1.' the block diagram of the a/d module is shown in figure 57 . the a/d status bit adsf is set automatically when a/d conversion is completed and cleared when a/d conversion is in process. in addition, the adc unit sets the interrupt flag in the acon register after a conversion is complete (if ainten is set to '1'). the adc interrupts the cpu when the enable bit ainten is set. port 1 adc channel selects the p1sfs0 and p1sfs1 registers control the selection of the port 1 pin functions. when the p1sfs0 bit is '0,' the pin functions as a gpio. when bits are set to '1,' the pins are configured as alternate functions. a new p1sfs1 register se- lects which of the alternate functions is enabled. the adc channel is enabled when the bit in p1sfs1 is set to '1.' note: in the 52-pin package, there is no individual v ref pin because v ref is combined with av cc pin. figure 57. 10-bit adc analog mux select adc out - 10 bits adat 0 reg acon reg control 10-bit sar adc adat1 reg adc0 adc1 adc2 adc3 adc4 adc5 adc6 adc7 av ref p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 av ref ai07856
upsd34xx - analog-to-digital convertor (adc) 152/264 table 89. acon register (sfr 97h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 aintf ainten aden ads2 ads1 ads0 adst adsf details bit symbol function 7aintf adc interrupt flag. this bit must be cleared with software. 0 = no interrupt request 1 = the aintf flag is set when adsf goes from '0' to '1.' interrupts cpu when both aintf and ainten are set to '1.' 6ainten adc interrupt enable 0 = adc interrupt is disabled 1 = adc interrupt is enabled 5aden adc enable bit 0 = adc shut off and consumes no operating current 1 = enable adc. after adc is enabled, 16ms of calibration is needed before adst bit is set. 4.. 2 ads2.. 0 analog channel select 000 select channel 0 (p1.0) 001 select channel 0 (p1.1) 010 select channel 0 (p1.2) 011 select channel 0 (p1.3) 101 select channel 0 (p1.5) 110 select channel 0 (p1.6) 111 select channel 0 (p1.7) 1adst adc start bit 0 = force to zero 1 = start adc, then after one cycle, the bit is cleared to '0.' 0adsf adc status bit 0 = adc conversion is not completed 1 = adc conversion is completed. the bit can also be cleared with software.
153/264 upsd34xx - analog-to-digital convertor (adc) table 90. adcps register details (sfr 94h, reset value 00h) table 91. adat0 register (sfr 95h, reset value 00h) table 92. adat1 register (sfr 96h, reset value 00h) bit symbol function 7:4 ? reserved 3 adcce adc conversion reference clock enable 0 = adc reference clock is disabled (default) 1 = adc reference clock is enabled 2:0 adcps[2:0] adc reference clock prescaler only three prescaler values are allowed: adcps[2:0] = 0, for f osc frequency 16mhz or less. resulting adc clock is f osc . adcps[2:0] = 1, for f osc frequency 32mhz or less. resulting adc clock is f osc /2. adcps[2:0] = 2, for f osc frequency 32mhz > 40mhz. resulting adc clock is f osc /4. bit symbol function 7:0 ? store adc output, bit 7 - 0 bit symbol function 7:2 ? reserved 1.. 0 ? store adc output, bit 9, 8
upsd34xx - programmable counter array (pca) with pwm 154/264 programmable counter array (pca) with pwm there are two programmable counter array blocks (pca0 and pca1) in the upsd34xx. a pca block consists of a 16-bit up-counter, which is shared by three tcm (timer counter module). a tcm can be programmed to perform one of the following four functions: 1. capture mode: capture counter values by external input signals 2. timer mode 3. toggle output mode 4. pwm mode: fixed frequency (8-bit or 16-bit), programmable frequency (8-bit only) pca block the 16-bit up-counter in the pca block is a free- running counter (except in pwm mode with pro- grammable frequency). the counter has a choice of clock input: from an external pin, timer 0 over- flow, or pca clock. a pca block has 3 timer counter modules (tcm) which share the 16-bit counter output. the tcm can be configured to capture or compare counter value, generate a toggling output, or pwm func- tions. except for the pwm function, the other tcm functions can generate an interrupt when an event occurs. every tcm is connected to a port pin in port 4; the tcm pin can be configured as an event input, a pwms, a toggle output, or as external clock in- put. the pins are general i/o pins when not as- signed to the tcm. the tcm operation is configured by control regis- ters and capture/compare registers. table 93., page 155 lists the sfr registers in the pca blocks. figure 58. pca0 block diagram timer0 overflow p4.3/eci pcach0 8-bit pcacl0 8-bit clksel1 idle mode (from cpu) ovf0 int eovfi tcm0 tcm1 tcm2 pwm freq compare p4.0/cex0 p4.1/cex1 p4.2/cex2 16-bit up timer/counter clksel0 pcaidle pca0clk clear counter en_pca en_all ai07857
155/264 upsd34xx - programmable counter array (pca) with pwm table 93. pca0 and pca1 registers sfr address register name rw register function pca0 pca1 pca0 pca1 a2 ba pcacl0 pcacl1 rw the low 8 bits of pca 16-bit counter. a3 bb pcach0 pcach1 rw the high 8 bits of pca 16-bit counter. a4 bc pcacon0 pcacon1 rw control register ? enable pca, timer overflow flag , pca idle mode, and select clock source. a5 a5 pcasta n/a rw status register, interrupt status flags ? common for both pca block 0 and 1. a9, aa, ab bd, be, bf tcmmode0 tcmmode1 tcmmode2 tcmmode3 tcmmode4 tcmmode5 rw tcm mode ? capture, compare, and toggle enable interrupts ?pwm mode select. ac ad c1 c2 capcoml0 capcomh0 capcoml3 capcomh3 rw capture/compare registers of tcm0 af b1 c3 c4 capcoml1 capcomh1 capcoml4 capcomh4 rw capture/compare registers of tcm1 b2 b3 c5 c6 capcoml2 capcomh2 capcoml5 capcomh5 rw capture/compare registers of tcm2 b4 c7 pwmf0 pwmf1 rw the 8-bit register to program the pwm frequency. this register is used for programmable, 8-bit pwm mode only. fb fc ccon2 ccon3 rw specify the pre-scaler value of pca0 or pca1 clock input
upsd34xx - programmable counter array (pca) with pwm 156/264 pca clock selection the clock input to the 16-bit up counter in the pca block is user-programmable. the three clock sources are: ? pca prescaler clock (pca0clk, pca1clk) ? timer 0 overflow ? external clock, pin p4.3 or p4.7 the clock source is selected in the configuration register pcacon. the prescaler output clock pcaclk is the f osc divided by the divisor which is specified in the ccon2 or ccon3 register. when external clock is selected, the maximum clock frequency should not exceed f osc /4. table 94. ccon2 register bit definition (sfr 0fbh, reset value 10h) table 95. ccon3 register bit definition (sfr 0fch, reset value 10h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? pca0ce pca0ps3 pca0ps2 pca0ps1 pca0ps0 details bit symbol r/w definition 4pca0cer/w pca0 clock enable 0 = pca0clk is disabled 1 = pca0clk is enabled (default) 3:0 pca0ps [3:0] r/w pca0 prescaler f pca0clk = f osc / (2 ^ pca0ps[3:0]) divisor range: 1, 2, 4, 8, 16... 16384, 32768 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? pca1ce pca1ps3 pca1ps2 pca1ps1 pca1ps0 details bit symbol r/w definition 4pca1cer/w pca1 clock enable 0 = pca1clk is disabled 1 = pca1clk is enabled (default) 3:0 pca1ps [3:0] r/w pca1 prescaler f pca1clk = f osc / (2 ^ pca1ps[3:0]) divisor range: 1, 2, 4, 8, 16... 16384, 32768
157/264 upsd34xx - programmable counter array (pca) with pwm operation of tcm modes each of the tcm in a pca block supports four modes of operation. however, an exception is when the tcm is configured in pwm mode with programmable frequency. in this mode, all tcm in a pca block must be configured in the same mode or left to be not used. capture mode the capcom registers in the tcm are loaded with the counter values w hen an external pin input changes state. the user can configure the counter value to be loaded by positive edge, negative edge or any transition of the input signal. at loading, the tcm can generate an interrupt if it is enabled. timer mode the tcm modules can be configured as software timers by enable the comparator. the user writes a value to the capcom registers, which is then compared with the 16-bit counter. if there is a match, an interrupt can be generated to cpu. toggle mode in this mode, the user writes a value to the tcm's capcom registers and enables the comparator. when there is a match with the counter output, the output of the tcm pin toggles. this mode is a sim- ple extension of the timer mode. pwm mode - (x8), fixed frequency in this mode, one or all the tcm's can be config- ured to have a fixed frequency pwm output on the port pins. the pwm frequency depends on when the low byte of the counter overflows (modulo 256). the duty cycle of each tcm module can be specified in the capcomhn register. when the pca_counter_l value is equal to or greater than the value in capcomhn, the pwm output is switched to a high state. when the pca_counter_l register overflows, the content in capcomhn is loaded to capcomln and a new pwm pulse starts. figure 59. timer mode note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 match_timer intr 0 0 0 tcmmoden enable 8 8 match pcasta capcomln pcaclm pcachm 16-bit comparator capcomhn intfn 0 0 16-bit up timer/counter 8 8 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 reset write to capcomhn write to capcomln 1 0 en_flag d c ai07858
upsd34xx - programmable counter array (pca) with pwm 158/264 figure 60. pwm mode - (x8), fixed frequency note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 capcomhn overflow enable 8 pcaclm 8 capcomln 8-bit comparatorn cexn match s r q q set clr 0 0 tcmmoden 0 0 0 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 ai07859
159/264 upsd34xx - programmable counter array (pca) with pwm pwm mode - (x8), programmable frequency in this mode, the pwm frequency is not deter- mined by the overflow of the low byte of the counter. instead, the frequency is determined by the pwmfm register. the user can load a value in the pwmfm register, which is then compared to the low byte of the counter. if there is a match, the counter is cleared and the load registers (pwmfm, capcomhn) are re-loaded for the next pwm pulse. there is only one pwmfm register which serves all 3 tcm in a pca block. if one of the tcm modules is operating in this mode, the other modules in the pca must be con- figured to the same mode or left not to be used. the duty cycle of the pwm can be specified in the capcomhn register as in the pwm with fixed frequency mode. different tcm modules can have their own duty cycle. note: the value in the frequency register (pwm- fm) must be larger than the duty cycle register (capcom). figure 61. pwm mode - (x8) programmable frequency note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 clr pcachm pwm freq compare pwmfm = pcaclm pcaclm capcomhn cexn enable enable 8 8 pwmfm 8-bit comparatorm 8-bit comparatorn capcomln match s r q q set clr 8 0 0 tcmmoden 0 0 0 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 ai07860
upsd34xx - programmable counter array (pca) with pwm 160/264 pwm mode - fixed frequency, 16-bit the operation of the 16-bit pwm is the same as the 8-bit pwm with fixed frequency. in this mode, one or all the tcm can be configured to have a fixed frequency pwm output on the port pins. the pwm frequency is depending on the clock input frequency to the 16-bit counter. the duty cycle of each tcm module can be specified in the cap- comhn and capcomln registers. when the 16- bit pca_counter is equal or greater than the val- ues in registers capcomhn and capcomln, the pwm output is switched to a high state. when the pca_counter overflows, cexn is asserted low. pwm mode - fixed frequency, 10-bit the 10-bit pwm logic requires that all 3 tcms in pca0 or pca1 operate in the same 10-bit pwm mode. the 10-bit pwm operates in a similar man- ner as the 16-bit pwm, except the pcachm and pcaclm counters are reconfigured as 10-bit counters. the capcomhn and capcomln reg- isters become 10-bit registers. pwm duty cycle of each tcm module can be specified in the 10-bit capcomhn and cap- comln registers. when the 10-bit pca counter is equal or greater than the values in the 10-bit registers capcomhn and capcomln, the pwm output switches to a high state. when the 10-bit pca counter overflows, the pwm pin is switched to a logic low and starts the next pwm pulse. the most-significant 6 bits in the pcachm counter and capcomh register are ?don?t cares? and have no effect on the pwm generation. writing to capture/compare registers when writing a 16-bit value to the pca capture/ compare registers, the low byte should always be written first. writing to capcomln clears the e_comp bit to '0'; writing to capcomhn sets e_comp to '1' the largest duty cycle is 100% (capcomhn capcomln = 0x0000), and the smallest duty cycle is 0.0015% (capcomhn capcomln = 0xffff). a 0% duty cycle may be generated by clearing the e_comp bit to ?0?. control register bit definition each pca has its own pca_confign, and each module within the pca block has its own tcm_mode register which defines the operation of that module (see table 96., page 160 through table 97., page 161 ). there is one pca_status register that covers both pca0 and pca1 (see table 98., page 162 ). table 96. pca0 control register pcacon0 (sfr 0a4h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 en-all en_pca eovfi pcaidle ? ? clk_sel[1:0] details bit symbol function 7en-all 0 = no impact on tcm modules 1 = enable both pca counters simult aneously (override the en_pca bits) this bit is to start the two 16-bit counters in the pca. fo r customers who want 5 pwm, for example, this bit can start all of the pwm outputs. 6en_pca 0 = pca counter is disabled 1 = pca counter is enabled en_pca counter run control bit. set with so ftware to turn the pca counter on. must be cleared with software to turn the pca counter off. 5 eovfi 1 = enable counter overflow inte rrupt if overflow flag (ovf) is set 4pcaidle 0 = pca operates when cpu is in idle mode 1 = pca stops running when cpu is in idle mode 3?reserved 2 10b_pwm 0 = select 16-bit pwm 1 = select 10-bit pwm 1-0 clk_sel [1:0] 00 select prescaler clock as counter clock 01 select timer 0 overflow 10 select external clock pin (p4.3 for pca0) (max clock rate = f osc /4)
161/264 upsd34xx - programmable counter array (pca) with pwm table 97. pca1 control register pcacon1 (sfr 0bch, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? en_pca eovfi pcaidle ? ? clk_sel[1:0] details bit symbol function 6en_pca 0 = pca counter is disabled 1 = pca counter is enabled en_pca counter run control bit. set with so ftware to turn the pca counter on. must be cleared with software to turn the pca counter off. 5 eovfi 1 = enable counter overflow inte rrupt if overflow flag (ovf) is set 4pcaidle 0 = pca operates when cpu is in idle mode 1 = pca stops running when cpu is in idle mode 3?reserved 2 10b_pwm 0 = select 16-bit pwm 1 = select 10-bit pwm 1-0 clk_sel [1:0] 00 select prescaler clock as counter clock 01 select timer 0 overflow 10 select external clock pin (p4.7 for pca1) (max clock rate = f osc /4)
upsd34xx - programmable counter array (pca) with pwm 162/264 table 98. pca status register pcasta (sfr 0a5h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ovf1 intf5 intf4 intf3 ovf0 intf2 intf1 intf0 details bit symbol function 7ofv1 pca1 counter overflow flag set by hardware when the counter rolls over. ovf1 flags an interrupt if bit eovfi in pcacon1 is set. ovf1 may be set with ei ther hardware or software but can only be cleared with software. 6intf5 tcm5 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 5intf4 tcm4 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 4intf3 tcm3 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 3ovf0 pca0 counter overflow flag set by hardware when the counter rolls over. ovf0 flags an interrupt if bit eovfi in pcacon0 is set. ovf1 may be set with ei ther hardware or software but can only be cleared with software. 2intf2 tcm2 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 1intf1 tcm1 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 0intf0 tcm0 interrupt flag set by hardware when a match or capture event occurs. must be clear with software.
163/264 upsd34xx - programmable counter array (pca) with pwm tcm interrupts there are 8 tcm interrupts: 6 match or capture in- terrupts and two counter overflow interrupts. the 8 interrupts are ?ored? as one pca interrupt to the cpu. by the nature of pca applic ation, it is unlikely that many of the interrupts occur simultaneously. if they do, the cpu has to read the interrupt flags and determine which one to serve. the software has to clear the interrupt flag in the status register after serving the interrupt. table 99. tcmmode0 - tcmmode5 (6 registers, reset value 00h) table 100. tcmmode register configurations note: 1. 10-bit pwm mode requires the 10b_pwm bit in the pcacon register set to '1.' bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] details bit symbol function 7 eintf 1 - enable the interrupt flags (intf) in the status register to generate an interrupt. 6 e_comp 1 - enable the comparator when set 5 cap_pe 1 - enable capture mode, a positive edge on the cexn pin. 4 cap_ne 1 - enable capture mode, a negative edge on the cexn pin. 3 match 1 - a match from the comparator sets the intf bits in the status register. 2 toggle 1 - a match on the comparator re sults in a toggling output on cexn pin. 1-0 pwm[1:0] 01 enable pwm mode (x8), fixed frequency. enable the cexn pin as a pwm output. 10 enable pwm mode (x8) with programmable frequency. enable the cexn pin as a pwm output. 11 enable pwm mode (x10 or x16), fixed frequency. enable the cexn pin as a pwm output. eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 tcm function 0 0 0 0 0 0 0 0 no operation (reset value) 0 1 0 0 0 0 0 1 8-bit pwm, fixed frequency 01 0 00 010 8-bit pwm, programmable frequency 01 0 00 011 10-bit or 16-bit pmw, fixed frequency (1) x 1 0 0 1 1 0 0 16-bit toggle x 1 0 0 1 0 0 0 16-bit software timer x x 0 1 0 0 0 0 16-bit capture, negative trigger x x 1 0 0 0 0 0 16-bit capture, positive trigger x x 1 1 0 0 0 0 16-bit capture, transition trigger
upsd34xx - psd module 164/264 psd module the psd module is stacked with the mcu module to form the upsd34xx, see hardware description, page 14 . details of the psd mod- ule are shown in figure 62 . the two separate modules interface with each other at the 8032 ad- dress, data, and control in terface blocks in figure 62 . figure 62. psd module block diagram pd1 pd2 port d pa 0 pa 1 pa 2 pa 3 pa 4 pa 5 pa 6 pa 7 pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 port b general pld 20 input macrocells 16 output macrocells a b a b a b a b a b a b a b a b b c b c b c b c b c b c b c b c security lock pld input bus pin feedback node feedback psd module: upsd34xx decode pld and-or array fs0-7 aaaaaaaa bbbbbbbb c c c c to pld input bus pc0 pc1 pc2 pc3 pc4 pc5 pc6 pc7 port c jtag-isp to all areas of psd module addr, data, control bus linked to 8032 mcu runtime control, 256 regs gpio, vm, page power mngmt csiop pld csboot0-3 external chip- selects main flash memory up to 8 segments up to 256 kbytes total fs0 fs7 2nd flash memory up to 4 segments up to 32 kbytes total csboot0 csboot3 data low address latch data high address latch a0-a7 a8-a15 8032 mux addr/data ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 8032 mux addr/data ad8 ad9 ad10 ad11 ad12 ad13 ad14 ad15 8032 control psen ale rd wr rst 8032 mcu module port a (80-pin only) to jtag debug on mcu gpio pld gpio gpio gpio 8 pin inputs mcu read or write mcu read pld out pld out pld out pld out pld out jtag cntl 8 pin inputs 4 pin inputs mcu read or write rs0 up to 8 kbytes sram page reg jtag omc allo- cator and-or array 69 inputs 69 inputs ai10454 pld input bus
165/264 upsd34xx - psd module psd module functional description major functional blocks are shown in figure 62., page 164 . the next sections describe each major block. 8032 address/data/control interface. these signals attach directly to the mcu module to im- plement a 16-bit multiplexed 8051-style bus be- tween the two stacked die. the mcu instruction prefetch and branch cache logic resides on the mcu module, leaving a modified 8051-style mem- ory interface on the psd module. the active-low reset signal originating from the mcu module goes to the psd module reset input (rst ). this reset signal can then be routed as an external output from the upsd34xx to the system pc board, if needed, through any one of the pld output pins as active-high or active-low logic by specifying logic equations in psdsoft express. the 8032 address and data busses are routed throughout the psd module as shown in figure 62 connecting many elements on the psd module to the 8032 mcu. the 8032 bus is not only connect- ed to the memories, but also to the general pld, making it possible for the 8032 to directly read and write individual logic macrocells inside the general pld. dual flash memories and iap. upsd34xx de- vices contain two independent flash memory ar- rays. this means that the 8032 can read instructions from one flash memory array while erasing or writing the other flash memory array. concurrent operation like this enables robust re- mote updates of firmware, also known as in-appli- cation programming (iap). iap can occur using any upsd34xx interface (e.g., uart, i2c, spi). concurrent memory operation also enables the designer to emulate eeprom memory within ei- ther of the two flash memory arrays for small data sets that have frequent updates. the 8032 can erase flash memories by individual sectors or it can erase an entire flash memory ar- ray at one time. each sector in either flash mem- ory may be individually write protected, blocking any writes from the 8032 (good for boot and start-up code protection). the flash memories au- tomatically go to standby between 8032 read or write accesses to conserve power. minimum erase cycles is 100k and minimum data retention is 15 years. flash memory, as well as the entire psd module may be programmed with the jtag in-system programming (isp) interface with no 8032 involvement, good for manufacturing and lab development. main flash memory. the main flash memory is divided into equal sized sectors that are individual- ly selectable by the de code pld output signals, named fsx, one signal for each main flash mem- ory sector. each flash sector can be located at any address within 8032 program address space (accessed with psen ) or data address space, also known as 8032 xdata space (accessed with rd or wr ), as defined with the software develop- ment tool, psdsoft express. the user only has to specify an address range for each segment and specify if main flash me mory will reside in 8032 data or program address space, and then psen , rd , or wr are automatically activated for the specified range. 8032 firmware is easily pro- grammed into main flash memory using psdsoft express or other software tools. see table 101., page 166 for main flash sector sizes on the various upsd34xx devices. secondary flash memory. the smaller second- ary flash memory is also divided into equal sized sectors that are individually selectable by the de- code pld signals, named csbootx, one signal for each secondary flash memory sector. each sector can be located at any address within 8032 program address space (accessed with psen ) or xdata space (accessed with rd or wr ) as de- fined with psdsoft express. the user only has to specify an address range for each segment, and specify if secondary fl ash memory will reside in 8032 data or program address space, and then psen , rd , or wr are automatically activated for the specified range. 8032 firmware is easily pro- grammed into secondary flash memory using ps- dsoft express and others. see table 101., page 166 for secondary flash sector sizes. sram. the sram is selected by a single signal, named rs0, from the decode pld. sram may be located at any address within 8032 xdata space (accessed with rd or wr ). these choices are specified using psdsoft express, where the user specifies an sram address range. see table 101., page 166 for sram sizes. the sram may optionally be backed up by an ex- ternal battery (or other dc source) to make its con- tents non-volatile (see sram standby mode (battery backup), page 224 ).
upsd34xx - psd module 166/264 table 101. upsd34xx memory configuration runtime control registers, csiop. a block of 256 bytes is decoded inside the psd module for module control and status (see table 106., page 176 ). the base address of these 256 locations is referred to in this data sheet as csiop (chip select i/o port), and is selected by the de- code pld output signal, csiop. the csiop regis- ters are always viewed by the 8032 as xdata, and are accessed with rd and wr signals. the address range of csiop is specified using psdsoft express where the user only has to specify an ad- dress range of 256 bytes, and then the rd or wr signals are automatically activated for the speci- fied range. individual registers within this block are accessed with an offset from the specified csiop base address. 39 registers are used out of the 256 locations to control the output state of i/o pins, to read i/o pins, to set the memory page, to control 8032 program and data address space, to control power management, to read/write macrocells inside the general pld, and other functions during runtime. unused locations within csiop are re- served and should not be accessed. memory page register. 8032 mcu architecture has an inherent size limit of 64k bytes in either program address space or xdata space. some upsd34xx devices have mu ch more memory that 64k, so special logic such as this page register is needed to access the extra memory. this 8-bit page register (figure 63 ) can be loaded and read by the 8032 at runtime as one of the csiop regis- ters. page register outputs feed directly into both plds creating extended address signals used to ?page? memory beyond the 64k byte limit (pro- gram space or xdata). most 8051 compilers di- rectly support memory paging, also known as memory banking. if memory paging is not needed, or if not all eight page register bits are needed for memory paging, the remaining bits may be used in the general pld for general logic. page register outputs are cleared to logic ?0? at reset and power- up. programmable logic (plds) . the upsd34xx contains two plds ( figure 74., page 188 ) that may optionally run in turbo or non-turbo mode. plds operate faster (less propagation delay) while in turbo mode but consume more power than in non-turbo mode. non-turbo mode allows the plds to go to standby automatically when no pld inputs are changing to conserve power. the logic configuration (from equations) of both plds is stored with non-volatile flash technology and the logic is active upon power-up. plds may not be programmed by the 8032, pld program- ming only occurs through the jtag interface. figure 63. memory page register device main flash memory secondary flash memory sram total flash size (bytes) individual sector size (bytes) number of sectors (sector select signal) total flash size (bytes) individual sector size (bytes) number of sectors (sector select signal) sram size (bytes) upsd3422 64k 16k 4 (fs0-3) 32k 8k 4 (csboot0-3) 4k upsd3433 128k 16k 8 (fs0-7) 32k 8k 4 (csboot0-3) 8k upsd3434 256k 32k 8 (fs0-7) 32k 8k 4 (csboot0-3) 8k 8032 data bus load or read via csiop + offset e0h d0 d7 d6 d5 d4 d3 d2 d1 q0 q7 q6 q5 q4 q3 q2 q1 dpld and gpld page register chip- selects and general logic rst (psd module reset) rst pgr0-7 ai09172
167/264 upsd34xx - psd module pld #1, decode pld (dpld). this programma- ble logic implements memory mapping and is used to select one of the individual main flash memory segments, one of individual secondary flash memory segments, the sram, or the group of csiop registers when the 8032 presents an ad- dress to dpld inputs (see figure 75., page 190 ). the dpld can also optionally drive external chip select signals on port d pins. the dpld also op- tionally produces two select signals (psel0 and psel1) used to enable a special data bus repeat- er function on port a, referred to as peripheral i/o mode. there are 69 dpld input signals which in- clude: 8032 address and control signals, page register outputs, psd module port pin inputs, and gpld logic feedback. pld #2, general pld (gpld). this program- mable logic is used to create both combinatorial and sequential general purpose logic (see figure 76., page 192 ). the gpld contains 16 output macrocells (omcs) and 20 input macrocells (imcs). output macrocell registers are unique in that they have direct connection to the 8032 data bus allowing them to be loaded and read directly by the 8032 at runtime through omc registers in csiop. this direct access is good for making small peripheral devices (shifters, counters, state ma- chines, etc.) that are accessed directly by the 8032 with little overhead. there are 69 gpld inputs which include: 8032 address and control signals, page register outputs, psd module port pin in- puts, and gpld feedback. omcs. there are two banks of eight omcs inside the gpld, mcellab, and mcellbc, totalling 16 omcs all together. each individual omc is a base logic element consisting of a flip-flop and some and-or logic ( figure 77., page 193 ). the gener- al structure of the gpld with omcs is similar in nature to a 22v10 pld de vice with the familiar sum-of-products (and-or) construct. true and compliment versions of 69 input signals are avail- able to the inputs of a large and-or array. and- or array outputs feed into an or gate within each omc, creating up to 10 product-terms for each omc. logic output of the or gate can be passed on as combinatorial logic or combined with a flip- flop within in each omc to realize sequential logic. omc outputs can be used as a buried nodes driv- ing internal feedback to the and-or array, or omc outputs can be routed to external pins on ports a, b, or c through the omc allocator. omc allocator. the omc allocator ( figure 78., page 194 ) will route eight of the omcs from mcellab to pins on either port a or port b, and will route eight of the omcs from mcellbc to pins on either port b or port c, based on what is specified in psdsoft express. imcs. inputs from pins on ports a, b, and c are routed to imcs for condit ioning (clocking or latch- ing) as they enter the chip, which is good for sam- pling and debouncing inputs. alternatively, imcs can pass port input signals directly to pld inputs without clocking or latching ( figure 79., page 198 ). the 8032 may read the imcs asynchronously at any time through imc registers in csiop. note: the jtag signals tdo, tdi, tck, and tms on port c do not route through imcs, but go direct- ly to jtag logic. i/o ports. for 80-pin upsd34xx devices, the psd module has 22 individually configurable i/o pins distributed over four ports (these i/o are in addition to i/o on mcu module). for 52-pin upsd34xx devices, the psd module has 13 indi- vidually configurable i/o pins distributed over three ports. see figure 85., page 212 for i/o port pin availability on these two packages. i/o port pins on the psd module (ports a, b, c, and d) are completely separate from the port pins on the mcu module (ports 1, 3, and 4). they even have different electrical characteristics. i/o port pins on the psd module are accessed by csiop registers, or they are controlled by pld equations. conversely, i/o port pins on the mcu module are controlled by the 8032 sfr registers. table 102. general i/o pins on psd module note: four pins on port c are dedicated to jtag, leaving four pins for general i/o. pkg port a port b port c port d total 52-pin 0 8 4 1 13 80-pin 8 8 4 2 22
upsd34xx - psd module 168/264 each i/o pin on the psd module can be individu- ally configured for different functions on a pin-by- pin basis ( figure 80., page 200 ). following are the available functions on psd module i/o pins. ? mcu i/o: 8032 controls the output state of each port pin or it reads input state of each port pin, by accessing csiop registers at run- time. the direction (in or out) of each pin is also controlled by csiop registers at run-time. ? pld i/o: psdsoft express logic equations and pin configuration selections determine if pins are connected to omc outputs or imc inputs. this is a stat ic and non-volatile configuration. port pins connected to pld outputs can no longer be driven by the 8032 using mcu i/o output mode. ? latched mcu address output: port a or port b can output de-multiplexed 8032 address signals a0 - a7 on a pin-by-pin basis as specified in csiop registers at run-time. in addition, port b can also be configured to output de-multiplexed a8-a15 in psdsoft express. ? data bus repeater: port a can bi- directionally buffer the 8032 data bus (de- multiplexed) for a specified address range in psdsoft express. this is referred to as peripheral i/o mode in this document. ? open drain outputs: some port pins can function as open-drain as specified in csiop registers at run-time. ? pins on port d can be used for external chip- select outputs originating from the dpld, without consuming omc resources within the gpld. jtag port. in-system programming (isp) can be performed through the jtag signals on port c. this serial interface allows programming of the en- tire psd module device or subsections of the psd module (for example, only flash memory but not the plds) without the participation of the 8032. a blank upsd34xx device soldered to a circuit board can be completely programmed in 10 to 25 sec- onds. the four basic jtag signals on port c; tms, tck, tdi, and tdo form the ieee-1149.1 interface. the psd module does not implement the ieee-1149.1 boundary scan functions, but uses the jtag interface for isp an 8032 debug. the psd module can reside in a standard jtag chain with other jtag devi ces and it will remain in bypass mode when other devices pe rform jtag functions. isp programming time can be reduced as much as 30% by using two optional jtag signals on port c, tstat and terr , in addition to tms, tck, tdi and tdo, and this is referred to as ?6-pin jtag?. the flashlink jtag programming cable is available from stmicroelectronics and psdsoft express software is available at no charge from www.st.com/psm. more jtag isp information maybe found in the section titled ?jtag isp and debug? on page 137. the mcu module is also included in the jtag chain within the upsd34xx device for 8032 debug- ging and emulation. while debugging, the psd module is in bypass mode . conversely, during isp, the mcu module is in bypass mode. power management. the psd module has bits in csiop registers that are configured at run-time by the 8032 to reduce power consumption of the gpld. the turbo bit in the pmmr0 register can be set to logic ?1? and both plds will go to non- turbo mode, meaning it will latch its outputs and go to sleep until the next transition on its inputs. there is a slight pena lty in pld performance (longer propagation delay), but significant power savings are realized. going to non-turbo mode may require an additional wait state in the 8032 sfr, buscon, because memory decode signals are also delayed. the default state of the turbo bit is logic '0,' meaning by default, the gpld is in fast turbo mode until the user turns off turbo mode. additionally, bits in csiop registers pmmr0 and pmmr2 can be set by the 8032 to selectively block signals from entering both plds which fur- ther reduces power consumption. there is also an automatic power down counter that detects lack of 8032 activity and reduces power consumption on the psd module to its lowest level (see power management, page 168 ).
169/264 upsd34xx - psd module security and nvm sector protection. a pro- grammable security bit in the psd module pro- tects its contents from unauthorized viewing and copying. the security bit is specified in psdsoft express and programmed into the upsd34xx with jtag. once set, the security bit will block access of jtag programming equipment to the psd mod- ule flash memory and pld configuration, and also blocks jtag debugging access to the mcu mod- ule. the only way to defeat the security bit is to erase the entire psd module using jtag (the erase command is the only jtag command al- lowed after the security bit has been set), after which the device is blank and may be used again. additionally and independently, the contents of each individual flash memory sector can be write protected (sector protecti on) by configuration with psdsoft express. this is typically used to protect 8032 boot code from being corrupted by inadvert- ent writes to flash memory from the 8032. status of sector protection bits may be read (but not written) using two registers in csiop space. memory mapping there many different ways to place (or map) the address range of psd module memory and i/o depending on system requirements. the dpld provides complete mapp ing flexibility. figure 64 shows one possible system memory map. in this example, 128k bytes of main flash memory for a upsd3433 device is in 8032 program address space, and 32k bytes of secondary flash memo- ry, the sram, and csiop registers are all in 8032 xdata space. in figure 64 , the nomenclature fs0..fs7 are desig- nators for the individual sectors of main flash memory, 16k bytes each. csboot0..csboot3 are designators for the individual secondary flash memory segments, 8k bytes each. rs0 is the des- ignator for sram, and csiop designates the psd module control register set. the designer may easily specify memory mapping in a point-and-click software environment using psdsoft express, creating a non-volatile configu- ration when the dpld is programmed using jtag. 8032 program address space. in the example of figure 64 , six sectors of main flash memory (fs2.. fs7) are paged across three memory pages in the upper half of program address space, and the remaining two sectors of main flash memory (fs0, fs1) reside in the lower half of program ad- dress space, and these two sectors are indepen- dent of paging (they reside in ?common? program address space). this paged memory example is quite common and supported by many 8051 soft- ware compilers. 8032 data address space (xdata). four sec- tors of secondary flash memory reside in the up- per half of 8032 xdata space in the example of figure 64 . sram and csiop registers are in the lower half of xdata space. the 8032 sfr regis- ters and local sram inside the 8032 mcu module do not reside in xdata space, so it is ok to place psd module sram or csiop registers at an ad- dress that overlaps the address of internal 8032 mcu module sram and registers. figure 64. typical system memory map 0000h 8000h a000h c000h e000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot0 8kb csboot1 8kb csboot2 8kb csboot3 8kb page x fs0 , 16kb common memory to all pages fs7 16kb fs5 16kb fs3 16kb rs0 , 8kb page 0 page 2 page 1 2000h 0000h 8000h ffffh system i/o fs6 16kb fs4 16kb fs2 16kb fs1 , 16kb common memory to all pages c000h 4000h csiop 256b ai09173
upsd34xx - psd module 170/264 specifying the memory map with psdsoft ex- press. the memory map example shown in fig- ure 64., page 169 is implemented using psdsoft express in a point-and-click environment. psdsoft express will automatica lly generate hardware definition language (hdl) statements of the abel language for the dpld, such as those shown in table 103 . specifying these equations using psdsoft ex- press is very simple. for example, figure 65 , page 84 shows how to specify the chip-select equation for the 16k byte flash memory segment, fs4. no- tice fs4 is on memory p age 1. this specification process is repeated for all other flash memory segments, the sram, the csiop register block, and any external chip select signals that may be need- ed. table 103. hdl statement example generated from psdsoft express for memory map figure 65. psdsoft express memory mapping rs0 = ((address ^h0000) & (address ^h1fff)); csiop = ((address ^h2000) & (address ^h20ff)); fs0 = ((address ^h0000) & (address ^h3fff)); fs1 = ((address ^h4000) & (address ^h7fff)); fs2 = ((page == 0) & (address ^h8000) & (address ^hbfff)); fs3 = ((page == 0) & (address ^hc000) & (address ^hffff)); fs4 = ((page == 1) & (address ^h8000) & (address ^hbfff)); fs5 = ((page == 1) & (address ^hc000) & (address ^hffff)); fs6 = ((page == 2) & (address ^h8000) & (address ^hbfff)); fs7 = ((page == 2) & (address ^hc000) & (address ^hffff)); csboot0 = ((address ^h8000) & (address ^h9fff)); csboot1 = ((address ^ha000) & (address ^hbfff)); csboot2 = ((address ^hc000) & (address ^hdfff)); csboot3 = ((address ^he000) & (address ^hffff));
171/264 upsd34xx - psd module eeprom emulation. eeprom emulation is needed if it is desired to repeatedly change only a small number of bytes of data in flash memory. in this case eeprom emulat ion is needed because although flash memory can be written byte-by- byte, it must be erased sector-by-sector, it is not erasable byte-by-byte (unlike eeprom which is written and erased byte-by-byte). so changing one or two bytes in flash memory typically re- quires erasing an entire sector each time only one byte is changed within that sector. however, two of the 8k byte sectors of secondary flash memory may be used to emulate eeprom by using a linked-list software technique to create a small data set that is maintained by alternating between the two flash sectors. for example, a data set of 128 bytes is written and maintained by software in a distributed fashion across one 8k byte sector of secondary flash memory until it be- comes full. then the writing continues on the other 8k byte sector while erasing the first 8k byte sec- tor. this process repeats continuously, bouncing back and forth between the two 8k byte sectors. this creates a wear-leveling effect, which increas- es the effective number of erase cycles for a data set of 128 bytes to many times more than the base 100k erase cycles of the flash memory. eeprom emulation in flash memory is typically faster than writing to actual eeprom memory, and more reli- able because the last known value in a data set is maintained even if a write cycle is corrupted by a power outage. the eepr om emulation function can be called by the user?s firmware, making it ap- pear that the user is writing a single byte, or data record, thus hiding all of the data management that occurs within the two 8k byte flash sectors. eeprom emulation firmware for the upsd34xx is available from www.st.com/psm. alternative mapping schemes. here are more possible memory maps for the upsd3433. note: mapping examples would be slightly differ- ent for upsd3433 and upsd3434, because of the different sizes of individual flash memory sectors. ? figure 66. place the larger main flash memory into program space, but split the secondary flash in half, placing two of its sectors into xdata space and remaining two sectors into program space. this method allows the designer to put iap code (or boot code) into two sectors of secondary flash in program space, and use the other two secondary flash sectors for data storage, such as eeprom emul ation in xdata space. ? figure 67. place both the main and secondary flash memories into program space for maximum code storage, with no flash memory in xdata space. figure 66. mapping: split second flash in half figure 67. mapping: all flash in code space 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot1 , 8kb common memory to all pages csboot0 , 8kb common memory to all pages csboot2 8kb csboot3 8kb page x rs0 , 8kb csiop , 256b fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h 8000h ffffh nothing mapped fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o system i/o c000h 2100h 4000h 2000h ai09174 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot1 , 8kb common memory to all pages csboot0 , 8kb common memory to all pages csboot2 , 8kb common memory to all pages csboot3 , 8kb common memory to all pages page x rs0 , 8kb csiop , 256b fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h ffffh fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o c000h 2100h 2000h ai09175
upsd34xx - psd module 172/264 ? figure 68. place the larger main flash memory into xdata space and the smaller secondary flash into program space for systems that need a large amount of flash for data recording or large look-up tables, and not so much flash for 8032 firmware. figure 68. mapping: small code / big data it is also possible to ?r eclassify? the flash memo- ries during runtime, moving the memories be- tween xdata memory space and program memory space on-the-fly. this essentially means that the user can override the initial setting during run-time by writing to a csiop register (the vm reg- ister). this is useful for iap, because standard 8051 architecture does not allow writing to pro- gram space. for example, if the user wants to up- date firmware in main flash memory that is residing in program space, the user can temporari- ly ?reclassify? the main flash memory into xdata space to erase and rewrite it while executing iap code from the secondary flash memory in pro- gram space. after the writing is complete, the main flash can be ?reclassified? back to program space, then execution can continue from the new code in main flash memory. the mapping example of fig- ure 68 will accommodate this operation. memory sector select rules. when defining sector select signals (fsx, csbootx, rs0, csiop, pselx) in psdsoft express, the user must keep these rules in mind: ? main flash and secondary flash memory sector select signals may not be larger than their physical sector size as defined in table 101., page 166 . ? any main flash memory sector select may not be mapped in the same address range as another main flash sector select (cannot overlap segments of main flash on top of each other). ? any secondary flash memory sector select may not be mapped in the same address range as another secondary flash sector select (cannot overlap segments of secondary flash on top of each other). ? a secondary flash memory sector may overlap a main flash memory sector. in the case of overlap, priority is given to the secondary flash memory sector. ? sram, csiop, or pselx may overlap any flash memory sector. in the case of overlap, priority is given to sram, csiop, or pselx. note: pselx is for optional peripheral i/o mode on port a. ? the address range for sector selects for sram, pselx, and csiop must not overlap each other as they have the same priority, causing contention if overlapped. 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot0 8kb csboot1 8kb csboot2 8kb csboot3 8kb page x rs0 , 8kb common memory to all pages csiop , 256 bytes, common to all pages fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h 8000h ffffh nothing mapped fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o c000h 2100h 2000h ai09176
173/264 upsd34xx - psd module figure 69 illustrates the prio rity scheme of the memory elements of the psd module. priority re- fers to which memory will ultimately produce a byte of data or code to the 8032 mcu for a given bus cycle. any memory on a higher level can over- lap and has priority over any memory on a lower level. memories on the same level must not over- lap. example: fs0 is valid when the 8032 produces an address in the range of 8000h to bfffh. csboot0 is valid from 8000h to 9fffh. rs0 is valid from 8000h to 87ffh. any address from the 8032 in the range of rs0 always accesses the sram. any address in the range of csboot0 greater than 87ffh (and less than 9fffh) auto- matically addresses se condary flash memory. any address greater than 9fffh accesses main flash memory. one-half of the main flash memo- ry segment and one-fourth of the secondary flash memory segment cannot be accessed by the 8032. figure 69. psd module memory priority the vm register. one of the csiop registers (the vm register) controls whether or not the 8032 bus control signals rd , wr , and psen are routed to the main flash memory, or the secondary flash memory. routing of these signals to these psm module memories determines if memories reside in 8032 program address space, 8032 xdata space, or both. the initial setting of the vm regis- ter is determined by a choice in psdsoft express and programmed into the upsd34xx in a non-vol- atile fashion using jtag. this initial setting is loaded into the vm register upon power-up and also loaded upon any reset event. however, the 8032 may override the init ial vm register setting at run-time by writing to the vm register, which is useful for iap. table 104., page 174 defines bit functions within the vm register. note: bit 7, pio_en, is not related to the memory manipulation functions of bits 1, 2, 3, and 4. sram and csiop registers are always in xdata space and cannot reside in program space. figure 70., page 174 illustrates how the vm reg- ister affects the routing of rd , wr , and psen to the memories on the psd module. as an example, if we apply the value 0ch to the vm register to im- plement the memory map example shown in fig- ure 64., page 169 , then the routing of rd , wr , and psen would look like that shown in figure 71., page 175 . in this example, the configuration is specified in psdsoft express and programmed into the upsd34xx using jtag. upon power-on or any re- set condition, the non-vola tile value 0ch is loaded into the vm register. at runtime, the value 0ch in the vm register may be changed (overridden) by the 8032 if desired to implement iap or other func- tions. level 1 sram, csiop, and peripheral i/o mode highest priority level 2 secondary flash memory level 3 main flash memory lowest priority ai02867e
upsd34xx - psd module 174/264 table 104. vm register (address = csiop + offset e2h) note: 1. default value of bits 1, 2, 3, and 4 is loaded from non-volatile setting as specified from psdsoft express upon any rese t or power- up condition. the default value of these bits can be overridden by 8032 at run-time. 2. default value of bit 7 is zero upon any reset condition. figure 70. vm register control of memories bit 7 pio_en bit 6 bit 5 bit 4 main flash xdata space bit 3 secondary flash xdata space bit 2 main flash program space bit 1 secondary flash program space bit 0 0 = disable peripheral i/o mode on port a not used not used 0 = rd or wr cannot access main flash 0 = rd or wr cannot access secondary flash 0 = psen cannot access main flash 0 = psen cannot access secondary flash not used 1 = enable peripheral i/o mode on port a not used not used 1 = rd or wr can access main flash 1 = rd or wr can access secondary flash 1 = psen can access main flash 1 = psen can access secondary flash not used dpld main flash memory secondary flash memory cs cs fs0 - fs7 csboot0 - csboot3 wr vm reg bit 4 vm reg bit 3 vm reg bit 1 vm reg bit 2 rd wr oe wr oe 8032 address 53 other pld inputs psen ai10455
175/264 upsd34xx - psd module figure 71. vm register example corresponding to memory map example psd module data bus width the psd module functions as an 8-bit device to the mcu module except when the pfq is fetching instructions from the flash memory. when psen is active, the psd module always drives 16-bit data out onto the bus. the flash memories are 16-bit wide when it is in program memory space and are 8-bit wide when it is in the data space. when the flash memory is configured in both ?program space? and ?data space,? the flash will drive 16-bit in a psen cycle and operates as an 8-bit memory in read or write cycle. the sram, csiop, and external device are always in 8-bit data space. table 105. data width in different bus cycles note: x = na dpld main flash memory secondary flash memory cs cs fs0 - fs7 csboot0 - csboot3 wr oe wr oe 8032 address 53 other pld inputs wr psen rd vm register = 0ch ai10456 type of bus cycle main flash secondary flash sram csiop external device psen cycle (program memory) 16-bit 16-bit x x x read or write cycle (data memo ry) 8-bit 8-bit 8-bit 8-bit 8-bit flash programming cycle (flash write or reading status) 8-bit 8-bit x x x
upsd34xx - psd module 176/264 runtime control register definitions (csiop) the 39 csiop registers are defined in table 106 . the 8032 can access each re gister by the address offset (specified in table 106 ) added to the csiop base address that was specified in psdsoft ex- press. do not write to unused locations within the csiop block of 256 registers, they should remain logic zero. table 106. csiop registers and their offsets (in hexadecimal) register name port a (80-pin) port b port c port d other description link data in 00h 01h 10h 11h mcu i/o input mode. read to obtain current logic level of pins on ports a, b, c, or d. no writes. table 122., page 203 control 02h 03h selects mcui/o or latched address out mode. logic 0 = mcu i/o, 1 = 8032 addr out. write to select mode. read for status. table 134., page 208 data out 04h 05h 12h 13h mcu i/o output mode. write to set logic level on pins of ports a, b, c, or d. read to check status. this register has no effect if a port pin is driven by an omc output from pld. table 126., page 203 direction 06h 07h 14h 15h mcu i/o mode. configures port pin as input or output. write to set direction of port pins. logic 1 = out, logic 0 = in. read to check status. table 130., page 204 drive select 08h 09h 16h 17h write to configure port pins as either cmos push-pull or open drain on some pins, while selecting high slew rate on other pins. read to check status. default output type is cmos push-pull. table 136., page 210 input macrocells 0ah 0bh 18h read to obtain logic state of imcs. no writes. table 117., page 198 enable out och 0dh 1ah 1bh read state of output enable logic on each i/o port driver. 1 = driver output is enabled, 0 = driver is off, and it is in high impedance state. no writes. table 140., page 211 output macrocells ab (mcellab) 20h read logic state of mcellab outputs (bank of eight omcs). write to load mcellab flip-flops. table 113., page 196 output macrocells bc (mcellbc) 21h read logic state of mcellbc outputs (bank of eight omcs). write to load mcellbc flip-flops. table 114., page 196 mask macrocells ab 22h write to set mask for mcellab. logic '1' blocks reads/writes of omc. logic '0' will pass omc value. read to check status. table 115., page 197 mask macrocells bc 23h write to set mask for mcellbc. logic '1' blocks reads/writes of omc. logic '0' will pass omc value. read to check status. table 116., page 197
177/264 upsd34xx - psd module main flash sector protection c0h read to determine main flash sector protection setting (non -volatile) that was specified in psdsoft express. no writes. table 109., page 186 security bit and secondary flash sector protection c2h read to determine if psd module device security bit is active (non- volatile) logic 1 = device secured. also read to determine secondary flash protection setting (non -volatile) that was specified in psdsoft. no writes. table 110., page 186 pmmr0 b0h power management register 0. write and read. table 144., page 219 pmmr2 b4h power management register 2. write and read. table 145., page 219 pmmr3 c7h power management register 3. write and read. however, bit 1 can be cleared only by a reset condition. table 146., page 219 page e0h memory page register. write and read. figure 63., page 166 vm (virtual memory) e2h places psd module memories into 8032 program address space and/or 8032 xdata address space. (vm overrides initial non-volatile setting that was specified in psdsoft express. reset restores initial setting) table 104., page 174 register name port a (80-pin) port b port c port d other description link
upsd34xx - psd module 178/264 psd module detailed operation specific details are given here for the following key functional areas on the psd module: flash memories plds (dpld and gpld) i/o ports power management jtag isp and debug interface flash memory operation. the flash memories are accessed through the 8032 address, data, and control bus interfaces. flash memories (and sram) cannot be accessed by any other bus master other than the 8032 mcu (these are not dual-port memories). the 8032 cannot write to flash memory as it would an sram (supply address, supply data, supply wr strobe, assume the data was correctly written to memory). flash memory must first be ?unlocked? with a special instruction sequence of byte write operations to invoke an internal algo- rithm inside either flash memory array, then a sin- gle data byte is written (programmed) to the flash memory array, then programming status is checked by a byte read operation or by checking the ready/busy pin (pc3). table 107., page 179 lists all of the special in struction sequences to pro- gram a byte to either of the flash memory arrays, erase the arrays, and check for different types of status from the arrays. this unlocking sequence is typical for many flash memories to prevent accidental writes by errant code. however, it is poss ible to bypass this un- locking sequence to save time while intentionally programming flash memory. important: the 8032 may not read and exe- cute code from the same flash memory array for which it is directing an instruction sequence. or more simply stated, the 8032 may not read code from the same flash array that is writing or eras- ing. instead, the 8032 must execute code from an alternate memory (like sram or a different flash array) while sending inst ruction sequences to a given flash array. since the two flash memory ar- rays inside the psd module device are completely independent, the 8032 may read code from one array while sending instructions to the other. it is possible, however, to suspend a sector erase op- eration in one particular flash array in order to ac- cess a different sector within that same flash array, then resume the erase later. after a flash memory array is programmed or erased it will go to ?read array? mode, then the 8032 can read from flash memory just as it would read from any rom or sram device. flash memory instruction sequences. an in- struction sequence consists of a sequence of spe- cific byte write and byte read operations. each byte written to either flash memory array on the psd module is received by a state machine inside the flash array and sequentially decoded to exe- cute an embedded algorithm. the algorithm is ex- ecuted when the correct number of bytes are properly received and the time between two con- secutive bytes is shorter than the time-out period of 80s. some instruction sequences are struc- tured to include read ope rations after the initial write operations. an instruction sequence must be followed exactly. any invalid combination of instruction bytes or time-out between two consecutive bytes while ad- dressing flash memory resets the psd module flash logic into read array mode (where flash memory is read like a rom device). the flash memories support instruction sequences summa- rized in table 107., page 179 . program a byte unlock sequence bypass erase memory by array or by sector suspend or resume a sector erase reset to read array mode the first two bytes of an instruction sequence are 8032 bus write operations to ?unlock? the flash array, followed by writing a command byte. the bus operations consist of writing the data aah to address x555h during the first bus cycle and data 55h to address xaaah durin g the second bus cy- cle. 8032 address signals a12-a15 are ?don?t care? during the instruction sequence during write cycles. however, the appropriate sector select signal ( fsx or csbootx ) from the dpld must be active during the entire instruction se- quence to complete the entire 8032 address (this includes the page number when memory paging is used). ignoring a12-a15 means the user has more flexibility in memory ma pping. for example, in many traditional flash me mories, instruction se- quences must be written to addresses aaaah and 5555h, not xaaah and x555h like supported on the psd module. when the user has to write to aaaah and 5555h, the me mory mapping options are limited. the main flash and secondary flash memories each have the same in struction set shown in table 107., page 179 , but the sector select signals de- termine which memory ar ray will receive and exe- cute the instructions.
179/264 upsd34xx - psd module table 107. flash memory instruction sequences (1,2) instr. sequence bus cycle 1 bus cycle 2 bus cycle 3 bus cycle 4 bus cycle 5 bus cycle 6 bus cycle 7 link read memory contents (read array mode) read byte from any valid flash memory addr read memory contents., pa ge 180 program (write) a byte to flash memory write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write a0h to x555h ( command ) write data byte to address programming flash memory., pag e 181 bypass unlock write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 20h to x555h ( command ) bypassed unlock sequence, pa ge 184 program a byte to flash memory with bypassed unlock write a0h to xxxxh ( command ) write data byte to address bypassed unlock sequence, pa ge 184 reset bypass unlock write 90h to xxxxh ( command ) write 00h to xxxxh ( command ) bypassed unlock sequence, pa ge 184 flash bulk erase (3) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 80h to x555h ( command ) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 10h to x555h ( command ) flash bulk erase., page 184 flash sector erase write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 80h to x555h ( command ) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 30h to desired sector ( command ) write 30h to another sector ( command ) flash sector erase., page 185 suspend sector erase write b0h to address that activates fsx or csbootx where erase is in progress ( command ) suspend sector erase., page 185 resume sector erase write 30h to address that activates fsx or csbootx where desired to resume erase ( command ) resume sector erase., page 185
upsd34xx - psd module 180/264 note: 1. all values are in hexadecimal, x = don?t care 2. 8032 addresses a12 through a15 are ?don?t care? during the instruction sequence decoding. only address bits a0-a11 are used during decoding of flash memory instruction sequences. the individual sector select signal (fs0 - fs7 or csboot0-csboot3) which is active during the instruction sequence determines the complete address. 3. directing this command to any individual sector within a flash memory array will invoke the bulk erase of all flash memory se ctors within that array. reading flash memory. under typical condi- tions, the 8032 may read the flash memory using read operations (read bus cycles) just as it would a rom or ram device. alternately, the 8032 may use read operations to obtain status information about a program or erase operation that is currently in prog ress. the following sections describe the kinds of read operations. read memory contents. flash memory is placed in the read array mode after power-up, af- ter a psd module reset event, or after receiving a reset flash memory instruction sequence from the 8032. the 8032 can read flash memory con- tents using standard read bus cycles anytime the flash array is in read array mode. flash memo- ries will always be in read array mode when the array is not actively engaged in a program or erase operation. reading the erase/program status bits. the flash arrays provide several status bits to be used by the 8032 to confirm the completion of an erase or program operation on flash memory, shown in table 108., page 181 . the status bits can be read as many times as needed until an operation is complete. the 8032 performs a read operation to obtain these status bits while an erase or program oper- ation is being executed by the state machine in- side each flash memory array. data polling flag (dq7). while programming ei- ther flash memory, the 8032 may read the data polling flag bit (dq7), wh ich outputs the comple- ment of the d7 bit of the byte being programmed into flash memory. once the program operation is complete, dq7 is equal to d7 of the byte just pro- grammed into flash memory, indicating the pro- gram cycle has completed successfully. the correct select signal, fsx or csbootx, must be active during the entire polling procedure. polling may also be used to indicate when an erase operation has completed. during an erase operation, dq7 is '0.' after the erase is complete dq7 is '1.' the correct select signal, fsx or cs- bootx, must be active during the entire polling procedure. dq7 is valid after the fourth instruction byte write operation (for program instruction se- quence) or after the sixth instruction byte write operation (for erase instruction sequence). if all flash memory sectors to be erased are pro- tected, dq7 is reset to ?0? for about 100s, and then dq7 returns to the value of d7 of the previ- ously addressed byte. no erasure is performed. toggle flag (dq6). the flash memories offer an alternate way to determine when a flash memory program operation has completed. during the pro- gram operation and while the correct sector select fsx or csbootx is active, the toggle flag bit (dq6) toggles from '0' to '1' and '1' to ?0? on subse- quent attempts to read any byte of the same flash array. when the internal program operation is complete, the toggling stops and the data read on the data bus d0-7 is the actual value of the addressed memory byte. the device is now accessible for a new read or write operation. the operation is finished when two successive reads yield the same value for dq6. dq6 may also be used to indicate when an erase operation has completed. during an erase opera- tion, dq6 will toggle from '0' to '1' and '1' to ?0? until the erase operation is complete, then dq6 stops toggling. the erase is finished when two succes- sive reads yield the same value of dq6. the cor- rect sector select signal, fsx or csbootx, must be active during the entire procedure. dq6 is valid after the fourth instruction byte write operation (for program instruction se- quence) or after the sixth instruction byte write operation (for erase instruction sequence). if all the flash memory sectors selected for era- sure are protected, dq6 toggles to ?0? for about 100s, then returns value of d6 of the previously addressed byte. reset flash write f0h to address that activates fsx or csbootx in desired array. ( command ) reset flash, page 1 85 instr. sequence bus cycle 1 bus cycle 2 bus cycle 3 bus cycle 4 bus cycle 5 bus cycle 6 bus cycle 7 link
181/264 upsd34xx - psd module error flag (dq5). during a normal program or erase operation, the error flag bit (dq5) is to ?0?. this bit is set to ?1? when there is a failure during flash memory byte program, sector erase, or bulk erase operations. in the case of flash memory programming, dq5 bit indicates an attempt to program a flash mem- ory bit from the programmed state of '0,' to the erased state of 1, which is not valid. dq5 may also indicate a particular flash cell is damaged and cannot be programmed. in case of an error in a flash memory sector erase or byte program operation, the flash memory sec- tor in which the error occurred or to which the pro- grammed byte belongs must no longer be used. other flash memory sectors may still be used. dq5 is reset after a reset flash instruction se- quence. erase time-out flag (dq3). the erase time- out flag bit (dq3) reflects the time-out period al- lowed between two consecutive sector erase in- struction sequence bytes. if multiple sector erase commands are desired, the additional sector erase commands (30h) must be sent by the 8032 within 80us after the previous sector erase com- mand. dq3 is 0 before this time period has ex- pired, indicating it is ok to issue additional sector erase commands. dq3 will go to logic ?1? if the time has been longer than 80s since the previous sec- tor erase command (time has expired), indication that is not ok to send another sector erase com- mand. in this case, the 8032 must start a new sec- tor erase instruction sequence (unlock and command) beginning again after the current sec- tor erase operation has completed. programming flash memory. when a byte of flash memory is programmed, individual bits are programmed to logic '0.' cannot program a bit in flash memory to a logic ?1? once it has been pro- grammed to a logic '0.' a bit must be erased to log- ic ?1?, and programmed to logic '0.' that means flash memory must be erased prior to being pro- grammed. a byte of flash memory is erased to all 1s (ffh). the 8032 may erase the entire flash memory array all at once, or erase individual sec- tor-by-sector, but not erase byte-by-byte. howev- er, even though the flash memories cannot be erased byte-by-byte, the 8032 may program flash memory byte-by-byte. this means the 8032 does not need to program group of bytes (64, 128, etc.) at one time, like some flash memories. each flash memory requires the 8032 to send an instruction sequence to program a byte or to erase sectors (see table 107., page 179 ). if the byte to be programmed is in a protected flash memory sector, the instruction sequence is ignored. important: it is mandatory that a chip-select signal is active for the flash sector where a pro- gramming instruction sequence is targeted. the user must make sure that the correct chip-select equation, fsx or csbootx specified in psdsoft express matches the address range that the 8032 firmware is accessing, otherwise the instruction sequence will not be recognized by the flash ar- ray. if memory paging is used, be sure that the 8032 firmware sets the page register to the correct page number before issuing an instruction se- quence to the flash memory segment on a partic- ular memory page, otherwise the correct sector select signal will not become active. once the 8032 issues a flash memory program or erase instruction sequence, it must check the sta- tus bits for completion. the embedded algorithms that are invoked inside a flash memory array pro- vide several ways to give status to the 8032. sta- tus may be checked using any of three methods: data polling, data to ggle, or ready/busy (pin pc3). table 108. flash memory status bit definition note: 1. x = not guaranteed value, can be read either '1' or '0.' 2. dq7-dq0 represent the 8032 data bus bits, d7-d0. functional block fsx, or csbootx dq7 dq6 dq5 dq4 dq3 dq2 dq1 dq0 flash memory active (the desired segment is selected) data polling to g g l e flag error flag x erase time- out xxx
upsd34xx - psd module 182/264 data polling. polling on the data polling flag bit (dq7) is a method of checking whether a program or erase operation is in progress or has complet- ed. figure 72 shows the data polling algorithm. when the 8032 issues a program instruction se- quence, the embedded algorithm within the flash memory array begins. the 8032 then reads the lo- cation of the byte to be programmed in flash memory to check status. the data polling flag bit (dq7) of this location becomes the compliment of bit d7 of the original data byte to be programmed. the 8032 continues to poll this location, compar- ing the data polling flag bit (dq7) and monitoring the error flag bit (dq5). when the data polling flag bit (dq7) matches bit d7 of the original data, then the embedded algorithm is complete. if the error flag bit (dq5) is '1,' the 8032 should test the data polling flag bit (dq7) again since the data polling flag bit (dq7) ma y have changed simulta- neously with the error flag bit (dq5) (see figure 72 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte (indicating a bad flash cell) or if the 8032 attempted to program bit to logic ?1? when that bit was already programmed to logic ?0? (must erase to achieve logic ?1?). it is suggested (as with all flash memories) to read the location again after the embedded program- ming algorithm has completed, to compare the byte that was written to the flash memory with the byte that was intended to be written. when using the data polling method during an erase operation, figure 72 still applies. however, the data polling flag bit (dq7) is '0' until the erase operation is complete. a ?1? on the error flag bit (dq5) indicates a time-out condition on the erase cycle, a ?0? indicates no error. the 8032 can read any location within the sector being erased to get the data polling flag bit (dq7) and the error flag bit (dq5). psdsoft express generate s ansi c code func- tions the user may use to implement these data polling algorithms. figure 72. data polling flowchart read dq5 & dq7 at valid address start read dq7 fail pass ai01369b dq7 = data yes no yes no dq5 = 1 dq7 = data yes no
183/264 upsd34xx - psd module data toggle. checking the toggle flag bit (dq6) is another method of determining whether a program or erase operation is in progress or has completed. figure 73 shows the data toggle algo- rithm. when the 8032 issues a program instruction se- quence, the embedded algorithm within the flash memory array begins. the 8032 then reads the lo- cation of the byte to be programmed in flash memory to check status. the toggle flag bit (dq6) of this location toggles each time the 8032 reads this location until the embedded algorithm is complete. the 8032 continues to read this loca- tion, checking the toggle flag bit (dq6) and mon- itoring the error flag bit (dq5). when the toggle flag bit (dq6) stops toggling (two consecutive reads yield the same value), then the embedded algorithm is complete. if the error flag bit (dq5) is '1,' the 8032 should test the toggle flag bit (dq6) again, since the toggle flag bit (dq6) may have changed simultaneously with the error flag bit (dq5) (see figure 73 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte, or if the 8032 at- tempted to program bit to logic ?1? when that bit was already programmed to logic ?0? (must erase to achieve logic ?1?). it is suggested (as with all flash memories) to read the location again after the embedded program- ming algorithm has completed, to compare the byte that was written to flash memory with the byte that was intended to be written. when using the data toggle method during an erase operation, figure 73 still applies. the toggle flag bit (dq6) toggles until the erase operation is complete. a ?1? on the error flag bit (dq5) indi- cates a time-out condition on the erase cycle, a ?0? indicates no error. the 8032 can read any location within the sector being erased to get the toggle flag bit (dq6) and the error flag bit (dq5). psdsoft express generate s ansi c code func- tions the user may use to implement these data toggling algorithms. figure 73. data toggle flowchart read dq5 & dq6 start read dq6 fail pass ai01370b dq6 = toggle no no yes yes dq5 = 1 no yes dq6 = toggle
upsd34xx - psd module 184/264 ready/busy (pc3). this signal can be used to output the ready/busy status of a program or erase operation on either flash memory. the out- put on the ready/busy pin is a ?0? (busy) when ei- ther flash memory array is being written, or when either flash memory array is being erased. the output is a ?1? (ready) when no program or erase operation is in progress. to activate this function on this pin, the user must select the ?ready/busy ? selection in psdsoft expres s when configuring pin pc3. this pin may be polled by the 8032 or used as a 8032 interrupt to indicate when an erase or program operation is complete (requires routing the signal on pc board from pc3 back into a pin on the mcu module). this signal is also available internally on the psd module as an input to both plds (without routing a signal externally on pc board) and its signal name is ?rd_bsy?. the ready/ busy output can be probed during lab develop- ment to check the timing of flash memory pro- gramming in the system at run-time. bypassed unlock sequence. the bypass un- lock mode allows the 8032 to program bytes in the flash memories faster than using the standard flash program instruction sequences because the typical aah, 55h unlock bus cycles are bypassed for each byte that is programmed. bypassing the unlock sequence is typically used when the 8032 is intentionally programming a large number of bytes (such as during iap). after intentional pro- gramming is complete, typically the bypass mode would be disabled, and full protection is back in place to prevent unwante d writes to flash mem- ory. the bypass unlock mode is entered by first initiat- ing two unlock bus cycles. this is followed by a third write operation containing the bypass un- lock command, 20h (as shown in table 107., page 179 ). the flash memory array that re- ceived that sequence then enters the bypass un- lock mode. after this, a two bus cycle program operation is all that is required to program a byte in this mode. the first bus cycle in this shortened program instruction sequence contains the by- passed unlocked program command, a0h, to any valid address within the unlocked flash array. the second bus cycle contains the address and data of the byte to be programmed. programming status is checked using toggle, polling, or ready/busy just as before. additional data bytes are pro- grammed the same way until this bypass unlock mode is exited. to exit bypass unlock mode, the system must is- sue the reset bypass unlock instruction se- quence. the first bus cycle of this instruction must write 90h to any valid address within the unlocked flash array; the second bus cycle must write 00h to any valid address within the unlocked flash ar- ray. after this sequence the flash returns to read array mode. during bypass unlock mode, only the bypassed unlock program instructio n, or the reset bypass unlock instruction is valid , other instruction will be ignored. erasing flash memory. flash memory may be erased sector-by-sector, or an entire flash memo- ry array may be erased with one command (bulk). flash bulk erase. the flash bulk erase instruc- tion sequence uses six write operations fol- lowed by a read operation of the status register, as described in table 107., page 179 . if any byte of the bulk erase instruction sequence is wrong, the bulk erase instruction sequence aborts and the device is reset to the read array mode. the address provided by the 8032 during the flash bulk erase command sequence may select any one of the eight flash memory sector select sig- nals fsx or one of the four signals csbootx. an erase of the entire flas h memory array will occur in a particular array even though a command was sent to just one of the individual flash memory sectors within that array. during a bulk erase, the memory status may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the data polling flag bit (dq7). the error flag bit (dq5) returns a ?1? if there has been an erase failure. details of acquir- ing the status of the bulk erase operation are de- tailed in the section entitled ? programming flash memory., page 181 . during a bulk erase operation, the flash memory does not accept any other flash instruction se- quences.
185/264 upsd34xx - psd module flash sector erase. the sector erase instruc- tion sequence uses six wr ite operations, as de- scribed in table 107., page 179 . additional flash sector erase commands to other sectors within the same flash array may be issued by the 8032 if the additional commands are sent within a limit- ed amount of time. the erase time-out flag bit (dq3) reflects the time-out period allowed between two consecutive sector erase instruction sequence bytes. if multi- ple sector erase commands are desired, the addi- tional sector erase commands (30h) must be sent by the 8032 to another sector within 80s after the previous sector erase command. dq3 is 0 before this time period has expired, indicating it is ok to issue additional sector erase commands. dq3 will go to logic ?1? if the time has been longer than 80s since the previous sector erase command (time has expired), indicating that is not ok to send an- other sector erase command. in this case, the 8032 must start a new sector erase instruction se- quence (unlock and command), beginning again after the current sector erase operation has com- pleted. during a sector erase operation, the memory sta- tus may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the data polling flag bit (dq7), as detailed in reading the erase/program status bits, page 180 . during a sector erase operation, a flash memory accepts only reset flash and suspend sector erase instruction sequences. erasure of one flash memory sector may be suspended, in order to read data from another flash memory sector, and then resumed. the address provided with the initial flash sector erase command sequence ( table 107., page 179 ) must select the first desired sec- tor (fsx or csbootx) to erase. subsequent sec- tor erase commands that are appended within the time-out period must be addressed to other de- sired segments within the same flash memory ar- ray. suspend sector erase. when a sector erase operation is in progress, the suspend sector erase instruction sequence can be used to sus- pend the operation by writing b0h to any valid ad- dress within the flash array that currently is undergoing an erase operation. this allows read- ing of data from a different flash memory sector within the same array after the erase operation has been suspended. suspend sector erase is accepted only during an erase operation. there is up to 15s delay after the suspend sector erase command is accepted and the array goes to read array mode. the 8032 will monitor the tog- gle flag bit (dq6) to determine when the erase operation has halted and read array mode is ac- tive. if a suspend sector erase instruction sequence was executed, the following rules apply: ? attempting to read from a flash memory sector that was being erased outputs invalid data. ? reading from a flash memory sector that was not being erased is valid. ? the flash memory cannot be programmed, and only responds to resume sector erase and reset flash instruction sequences. ? if a reset flash instruction sequence is received, data in the flash memory sector that was being erased is invalid. resume sector erase. if a suspend sector erase instruction sequence was previously exe- cuted, the erase cycle may be resumed with this instruction sequence. the resume sector erase instruction sequence consists of writing the com- mand 30h to any valid address within the flash ar- ray that was suspended as shown in table 107., page 179 . reset flash. the reset flash instruction se- quence resets the embedded algorithm running on the state machine in the targeted flash memory (main or secondary) and the memory goes into read array mode. the re set flash instruction consists of one bus wr ite cycle as shown in ta- ble 107., page 179 , and it must be executed after any error condition that has occurred during a flash memory program or erase operation. it may take the flash memory up to 25s to com- plete the reset cycle. t he reset flash instruction sequence is ignored when it is issued during a program or bulk erase operation. the reset flash instruction sequence aborts any on-going sector erase operation and returns the flash memory to read array mode within 25s. reset signal applied to flash memory. when- ever the psd module receives a reset signal from the mcu module, any operation that is occurring in either flash memory arra y will be aborted and the array(s) will go to read ar ray mode. it may take up to 25s to abort an operation and achieve read array mode. a reset from the mcu modu le will result from any of these events: an active signal on the upsd34xx reset_in input pin, a watchdog timer time-out, detection of low v cc , or a jtag debug channel re- set event.
upsd34xx - psd module 186/264 flash memory sector protection. each flash memory sector can be separately protected against program and erase operations. this mode can be activated (or deactivated) by selecting this feature in psdsoft express and then programming through the jtag port. sector protection can be selected for individual sectors, and the 8032 can- not override the protection during run-time. the 8032 can read, but not change, sector protection. any attempt to program or erase a protected flash memory sector is ignored. the 8032 may read the contents of a flash sector even when a sector is protected. sector protection status is not read using flash memory instruction sequences, but instead this status is read by the 8032 reading two registers within csiop address space shown in table 109 and table 110 . flash memory protection during power-up. flash memory write operations are automatical- ly prevented while v dd is ramping up until it rises above v lko voltage threshold at which time flash memory write operations are allowed. psd module security bit. a programmable se- curity bit in the psd module protects its contents from unauthorized viewing and copying. the secu- rity bit is set using psdsoft express and pro- grammed into the psd module with jtag. when set, the security bit will block access of jtag pro- gramming equipment from reading or modifying the psd module flash memory and pld configu- ration. the security bit also blocks jtag access to the mcu module for debugging. the only way to defeat the security bit is to erase the entire psd module using jtag (erase is the only jtag oper- ation allowed while security bit is set), after which the device is blank and may be used again. the 8032 mcu will always have access to flash mem- ory contents through its 8-bit data bus even while the security bit is set. the 8032 can read the status of the security bit at run-time (but it cannot change it) by reading the csiop register defined in table 110 . table 109. main flash memory protection regist er definition (address = csiop + offset c0h) note: bit definitions: sec_prot 1 = flash memory sector is write protected, 0 = flash memory sector is not write protected. table 110. secondary flash memory protection/sec urity register definition (csiop + offset c2h) note: security_bit = 1, device is secured, 0 = not secured note: sec_prot 1 = flash memory sector is write protected, 0 = flash memory sector is not write protected. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sec7_prot sec6_prot sec5_prot sec4_prot sec3_prot sec2_prot sec1_prot sec0_prot bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 security_bit not used not used not used sec3_prot sec2_prot sec1_prot sec0_prot
187/264 upsd34xx - psd module plds. the psd module contains two plds: the decode pld (dpld), and the general pld (gpld), as shown in figure 74., page 188 . both plds are fed by a common pld input signal bus, and additionally, the gpld is connected to the 8032 data bus. pld logic is specified us ing psdsoft express and programmed into the psd module using the jtag isp channel. pld logic is non-volatile and avail- able at power-up. plds may not be programmed by the 8032. the plds have selectable levels of performance and power consumption. the dpld performs address decoding, and gen- erates select signals for internal and external com- ponents, such as memory, registers, and i/o ports. the dpld can generate external chip-select (ecs1-ecs2) signals on port d. the gpld can be used for logic functions, such as loadable counters and shift registers, state ma- chines, encoding and decoding logic. these logic functions can be constructed from a combination of 16 output macrocells (omc), 20 input macro- cells (imc), and the and-or array. routing of the 16 omcs outputs can be divided between pins on three ports a, b, or c by the omc allocator as shown in figure 78., page 194 . eight of the 16 omcs that can be routed to pins on port a or port b and are named mcellab0- mcellab7. the other eight omcs to be routed to pins on port b or port c and are named mcellbc0-mcellbc7. this routing depends on the pin number assignments that are specified in psdsoft express for ?pld outputs? in the pin def- inition section. omc outputs can also be routed in- ternally (not to pins) used as buried nodes to create shifters, counters, etc. the and-or array is used to form product terms. these product terms are configured from the logic definitions entered in psdsoft express. a pld in- put bus consisting of 69 signals is connected to both plds. input signals are shown in table 111 , both the true and compliment versions of each of these signals are available at inputs to each pld. note: the 8032 data bus, d0 - d7, does not route directly to pld inputs. instead, the 8032 data bus has indirect access to the gpld (not the dpld) when the 8032 reads and writes the omc and imc registers within csiop address space. turbo bit and plds. the plds can minimize power consumption by going to standby after all the pld inputs remain unchanged for an extended time (about 70ns). when the turbo bit is set to log- ic one (bit 3 of the csiop pmmr0 register), turbo mode is turned off and then this automatic standby mode is achieved. turning off turbo mode in- creases propagation delays while reducing power consumption. the default state of the turbo bit is logic zero, meaning turbo mode is on. additional- ly, four bits are available in the csiop pmmr0 and pmmr2 registers to block the 8032 bus control signals (rd , wr , psen , ale) from entering the plds. this reduces power consumption and can be used only when these 8032 control signals are not used in pld logic equations. see power management, page 218 . table 111. dpld and gpld inputs input source input name number of signals 8032 address bus a0-a15 16 8032 bus control signals psen , rd , wr , ale 4 reset from mcu module reset 1 power-down from auto- power down counter pdn 1 porta input macrocells (80-pin devices only) pa0-pa7 8 portb input macrocells pb0-pb7 8 portc input macrocells pc2, pc3, pc4, pc7 4 port d inputs (52-pin devices have only pd1) pd1, pd2 2 page register pgr0-pgr7 8 macrocell omc bank ab feedback mcellab fb0-7 8 macrocell omc bank bc feedback mcellbc fb0-7 8 flash memory status bit ready/busy 1
upsd34xx - psd module 188/264 figure 74. dpld and gpld gpld 20 input macrocells pld input bus pin feedback, ports a, b, c node feedback dpld main flash memory selects (fsx) aaaaaaaa bbbbbbbb c c c c 69 inputs omc allo- cator 4 or 8 2 or 4 secondary flash memory selects (csbootx) 1 sram select (rs0) 1 i/o port select (csiop) 2 periperal i/o mode range selects (pselx) 1 or 2 external device chip-selects (ecsx) 8 8 4 8 8 4 and-or array and-or array 8032 address 8032 bus control page register other signals 16 output macrocells port a (80-pin only) port c port b 8032 data bus pin feedback, port d port d 8032 data bus 8 pld out a b a b a b a b a b a b a b a b b c b c b c b c b c b c b c b c 8 pld out 69 inputs ai06600a
189/264 upsd34xx - psd module decode pld (dpld). the dpld ( figure 75., page 190 ) generates the following memory decode signals: eight main flash memory sector select signals (fs0-fs7) with three product terms each four secondary flash memory sector select signals (csboot0-csboot3) with three product terms each one sram select signal (rs0) with two product terms one select signal for the base address of 256 psd module device control and status registers (csiop) with one product term two external chip-select output signals for port d pins, each with one product term (52- pin devices only have one pin on port d) two chip-select signals (psel0, psel1) used to enable the 8032 data bus repeater function (peripheral i/o mode) for port a on 80-pin devices. each has one product term. a product term indicates the logical or of two or more inputs. for example, three product terms in a dpld output means the final output signal is ca- pable of representing the logical or of three differ- ent input signals, each input signal representing the logical and of a combination of the 69 pld in- puts. using the signal fs0 for example, the user may create a 3-product term chip select signal that is logic true when any one of three different address ranges are true... fs0 = address range 1 or ad- dress range 2 or address range 3. the phrase ?one product term? is a bit misleading, but commonly used in this context. one product term is the logical and of two or more inputs, with no or logic involved at all, such as the csiop sig- nal in figure 75., page 190 .
upsd34xx - psd module 190/264 figure 75. dpld logic array fs0 fs1 fs7 fs6 fs5 fs4 fs3 fs2 main flash memory sector selects csboot0 csboot3 csboot2 csboot1 secondary flash memory sector selects rs0 sram select csiop i/o & control registers select ecs0 ecs1 external chip- selects (port d) psel0 psel1 peripheral i/o mode range selects 8032 address (a0 - a15) 16 4 1 power-down indicator (pdn) 1 pin input ports a, b, c (imcs) 20 pin input port d 2 omc feedback (mcellab.fb0-7) 8 page register (pgr0 - pgr7) 8 8 1 omc feedback (mcellbc.fb0-7) pld input bus 3 3 3 3 3 3 3 3 3 3 3 3 2 1 1 1 1 1 number of product terms ai06601a psm module reset (rst) flash mem prog status (rdybsy) 8032 cntl (rd, wr, psen, ale)
191/264 upsd34xx - psd module general pld (gpld). the gpld is used to cre- ate general system logic. figure 74., page 188 shows the architecture of the entire gpld, and figure 76., page 192 shows the relationship be- tween one omc, one imc, and one i/o port pin, which is representative of pins on ports a, b, and c. it is important to understand how these ele- ments work together. a more detailed description will follow for the three major blocks (omc, imc, i/ o port) shown in figure 76 . figure 76 also shows which csiop registers to access for various pld and i/o functions. the gpld contains: 16 output macrocells (omc) 20 input macrocells (imc) omc allocator product term allocator inside each omc and-or array capable of generating up to 137 product terms three i/o ports, a, b, and c
upsd34xx - psd module 192/264 figure 76. gpld: one omc, one imc, and one i/o port (typical pin, port a, b, or c) output macrocell (omc) input macrocell (imc) flip-flop clock global clock flip-flop clear node feedback native product terms product term allocator product terms from other omcs i/o port logic peripheral i/o mode bit output enable latched 8032 addr bit psd module port pin 8032 data bit 8032 data bit output enable pin feedback clock or gate signal pld input bus omc out ale to other i/o port logic omc allo- cator reset psd module reset from other macrocell allocator global clock and-or array clock or gate reset flip-flop and other logic borrowed product terms pin input latch or pass input signal 8032 data bits 8032 data bits csiop registers (data out, direction control, drive) m u x omc output feed back direction control data out csiop registers (data in, data out, direction, control, drive, enable) csiop registers (mcellab, mcellbc) read omc load omc csiop registers (imca, imcb, imcc) read imc flip-flop preset pin input data i n 69 inputs 8032 rd 8032 rd 8032 rd 8032 wr 8032 wr 8032 address, data, control bus ai06602a
193/264 upsd34xx - psd module output macrocell. the gpld has 16 omcs. ar- chitecture of one individual omc is shown in fig- ure 77 . omcs can be used for internal node feedback (buried registers to build shift registers, etc.), or their outputs may be routed to external port pins. the user can choose any mixture of omcs used for buried functions and omcs used to drive port pins. referring to figure 77 , for each omc there are na- tive product terms available from the and-or ar- ray to form logic, and also borrowed product terms are available (if unused) from other omcs. the polarity of the final product term output is con- trolled by the xor gate. each omc can imple- ment sequential logic using the flip-flop element, or combinatorial logic when bypassing the flip-flop as selected by the output multiplexer. an omc output can drive a port pin through the omc allo- cator, it can also drive the 8032 data bus, and also it can drive a feedback path to the and-or array inputs, all at the same time. the flip-flop in each omc can be synthesized as a d, t, jk, or sr type in psdsoft express. omc flip- flops are specified using psdsoft express in the ?user defined nodes? section of the design assis- tant. each flip-flop?s clock, preset, and clear inputs may be driven individually from a product term of the and-or array, defined by equations in psd- soft express for signals *. c, *.pr, and *.re respec- tively. the preset and clear inputs on the flip-flops are level activated, active-high logic signals. the clock inputs on the flip-flops are rising-edge logic signals. optionally, the signal clkin (pin pd1) can be used for a common clock source to all omc flip- flops. each flip-flop is clocked on the rising edge. a common clock is specified in psdsoft express by assigning the function ?common clock input? for pin pd1 in the pin definition section, and then choosing the signal clkin when specifying the clock input (*.c) for individua l flip-flops in the ?user defined nodes? section. figure 77. detail of a single omc d clr pre q mux mux m u x m u x psdsoft psdsoft output macrocell (omc) pt preset (.pr) from and-or array borrowed pts pt clear (.re) node feedback (.fb) polarity select, psdsoft pt allocator, draws from local and global unused product terms. psdsoft dictates. lended pts data bit from 8032 data bit to 8032 indicates mcu write to particular csio omc register mcu overrides pt preset and clr during mcu write mcu read of particular csiop omc register omc output from and-or array to pld input bus from and-or array native pts allocated pts pt clock (.c) from and-or array global clock (clkin) from pld input bus 8032 address, data, control bus omc allo- cator o u t product terms from other omcs ai06617a
upsd34xx - psd module 194/264 omc allocator. outputs of the 16 omcs can be routed to a combination of pins on port a (80-pin devices only), port b, or port c as shown in figure 78 . omcs are routed to port pins automatically af- ter specifying pin numbers in psdsoft express. routing can occur on a bit-by-bit basis, spitting omc assignment between the ports. however, one omc can be routed to one only port pin, not both ports. product term allocator. each omc has a prod- uct term allocator as shown in figure 77., page 193 . psdsoft express uses pt alloca- tors to give and take product terms to and from other omcs to fit a logic design into the available silicon resources. this happens automatically in psdsoft express, but understanding how pt allo- cation works will help if the logic design does not ?fit?, in which case the us er may try selecting a dif- ferent pin or different omc for the logic where more product terms may be available. the follow- ing list summarizes how product terms are allocat- ed to each omc, as shown in table 112., page 195 . ? mcellab0-mcellab7 each have three native product terms and may borrow up to six more ? mcellbc0-mcellbc3 each have four native product terms and may borrow up to five more ? mcellbc4-mcellbc7 each have four native product terms and may borrow up to six more. native product terms come from the and-or ar- ray. each omc may borrow product terms only from certain other omcs, if they are not in use. product term allocation does not add any propaga- tion delay to the logic. the fitter report generated by psdsoft express will show any pt allocation that has occurred. if an equation requires more product terms than are available to it through pt allocation, then ?ex- ternal? product terms are required, which con- sumes other omcs. this is called product term expansion and also happens automatically in ps- dsoft express as needed. pt expansion causes additional propagation delay because an addition- al omc is consumed by the expansion process and its output is rerouted (or fed back) into the and-or array. the user can examine the fitter re- port generated by psdsoft express to see result- ing pt allocation and pt expansion (expansion will have signal names, such as ?*.fb_0? or ?*.fb_1?). psdsoft express will always tr y to fit the logic de- sign first by using pt allocation, and if that is not sufficient then psdsoft express will use pt expan- sion. product term expansion may occur in the dpld for complex chip select equations for flash mem- ory sectors and for sram, but this is a rare oc- curence. if psdsoft express does use pt expansion in the dpld, it results in an approxi- mate 15ns additional propagation delay for that chip select signal, which gives 15ns less time for the memory to respond. be aware of this and con- sider adding a wait state to the 8032 bus access (using the sfr named, buscon), or lower the 8032 clock frequency to avoid problems with memory access time. figure 78. omc allocator port c pins port b pins port a pins (80-pin pkg only) omc bank bc (mcellbc0-7) omc bank ab (mcellab0-7) 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 2 3 4 7 4 5 6 7 32 1 0 4 5 6 7 32 1 0 ** ** * = used for jtag, pin not available to gpld ai09177
195/264 upsd34xx - psd module table 112. omc port and data bit assignments note: 1. mcellab0-mcellab7 can be output to port a pins only on 80-pin devices. port a is not available on 52-pin devices 2. port pins pc0, pc1, pc5, and pc6 are dedicated jtag pins and are not available as outputs for mcellbc 0, 1, 5, or 6 omc port assignment (1,2) native product terms from and-or array maximum borrowed product terms data bit on 8032 data bus for loading or reading omc mcellab0 port a0 or b0 3 6 d0 mcellab1 port a1 or b1 3 6 d1 mcellab2 port a2 or b2 3 6 d2 mcellab3 port a3 or b3 3 6 d3 mcellab4 port a4 or b4 3 6 d4 mcellab5 port a5 or b5 3 6 d5 mcellab6 port a6 or b6 3 6 d6 mcellab7 port a7 or b7 3 6 d7 mcellbc0 port b0 4 5 d0 mcellbc1 port b1 4 5 d1 mcellbc2 port b or c2 4 5 d2 mcellbc3 port b3 or c3 4 5 d3 mcellbc4 port b4 or c4 4 6 d4 mcellbc5 port b5 4 6 d5 mcellbc6 port b6 4 6 d6 mcellbc7 port b7 orc7 4 6 d7
upsd34xx - psd module 196/264 loading and reading omcs. each of the two omc groups (eight omcs each) occupies a byte in csiop space, named mcellab and mcellbc (see table 113 and table 114 ). when the 8032 writes or reads these two omc registers in csiop it is accessing each of the omcs through its 8-bit data bus, with the bit assignment shown in table 112., page 195 . sometimes it is important to know the bit assignment when the user builds gpld log- ic that is accessed by the 8032. for example, the user may create a 4-bit counter that must be load- ed and read by the 8032, so the user must know which nibble in the corresponding csiop omc reg- ister the firmware must access. the fitter report generated by psdsoft express will indicate how it assigned the omcs and data bus bits to the logic. the user can optionally force psdsoft express to assign logic to specific omcs and data bus bits if desired by using the ?property? statement in psdsoft express. please see the psdsoft ex- press user?s manual for mo re information on omc assignments. loading the omc flip-flops with data from the 8032 takes priority over the pld logic functions. as such, the preset, clear, and clock inputs to the flip-flop can be asynchronously overridden when the 8032 writes to the csiop registers to load the in- dividual omcs. table 113. output macrocell mcellab (address = csiop + offset 20h) note: all bits clear to logic ?0? at power-on reset, but do not clear after warm reset conditions (non-power-on reset) table 114. output macrocell mcellbc (address = csiop + offset 21h) note: all bits clear to logic ?0? at power-on reset, but do not clear after warm reset conditions (non-power-on reset) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mcellab7 mcellab6 mcellab5 mcellab4 mcellab3 mcellab2 mcellab1 mcellab0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mcellbc7 mcellbc6 mcellbc5 mcellbc4 mcellbc3 mcellbc2 mcellbc1 mcellbc0
197/264 upsd34xx - psd module omc mask registers. there is one omc mask register for each of the two groups of eight omcs shown in table 115 and table 116 . the omc mask registers are used to block loading of data to individual omcs. the default value for the mask registers is 00h, which a llows loading of all omcs. when a given bit in a mask register is set to a '1,' the 8032 is blocked from writing to the associated omc flip-flop. for example, suppose that only four of eight omcs (mcellab0-3) are being used for a state machine. the user may not want the 8032 to write to all the omcs in mcellab because it would overwrite the state machine registers. therefore, the user would want to load the mask register for mcellab with the value 0fh before writing omcs. table 115. output macrocell mcellab mask register (address = csiop + offset 22h) note: 1. default is 00h after any reset condition 2. 1 = block writing to individual macrocell, 0 = allow writing to individual macrocell table 116. output macrocell mcellbc mask register (address = csiop + offset 23h) note: 1. default is 00h after any reset condition 2. 1 = block writing to individual macrocell, 0 = allow writing to individual macrocell input macrocells. the gpld has 20 imcs, one for each pin on port a (80-pin device only), one for each pin on port b, and for the four pins on port c that are not jtag pins. the architecture of one in- dividual imc is shown in figure 79., page 198 . imcs are individually configurable, and they can strobe a signal coming in from a port pin as a latch (gated), or as a register (clocked), or the imc can pass the signal without strobing, all prior to driving the signal onto the pld input bus. strobing is use- ful for sampling and debouncing inputs (keypad in- puts, etc.) before entering the pld and-or arrays. the outputs of imcs can be read by the 8032 asynchronously when the 8032 reads the csiop registers shown in table 117 , table 118 , and table 119., page 198 . it is possible to read a psd module port pin using one of two different methods, one method is by reading imcs as de- scribed here, the other method is using mcu i/o mode described in a later section. the optional imc clocking or gating signal used to strobe pin inputs is driven by a product term from the and-or array. there is one clocking or gating product term available for each group of four imcs. port inputs 0-3 are controlled by one prod- uct term and 4-7 by another. to specify in psdsoft express the method in which a signal will be strobed as it enters an imc for a given input pin on port a, b, or c, just specify ?pt clocked register? to use a rising edge to clock the incoming signal, or specify ?pt clock latch? to use an active high gate signal to latch the incoming signal. then de- fine an equation for the imc clock (.ld) or the imc gate (.le) signal in the ?i/o equations? section. if the user would like to latch an incoming signal using the gate signal ale from the 8032, then in psdsoft express, for a given input pin on port a, b, or c, specify ?latched address? as the pin func- tion. if it is desired to pass an incoming signal through an imc directly to the and-or array inputs with- out clocking or gating (this is most common), in psdsoft express simply specify ?logic or ad- dress? for the input pin function on port a, b, or c. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mask mcellab7 mask mcellab6 mask mcellab5 mask mcellab4 mask mcellab3 mask mcellab2 mask mcellab1 mask mcellab0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mask mcellbc7 mask mcellbc6 mask mcellbc5 mask mcellbc4 mask mcellbc3 mask mcellbc2 mask mcellbc1 mask mcellbc0
upsd34xx - psd module 198/264 figure 79. detail of a single imc table 117. input macrocell port a (1) (address = csiop + offset 0ah) note: 1. port a not available on 52-pin upsd34xx devices 2. 1 = current state of imc is logic '1,' 0 = current state is logic ?0? table 118. input macrocell port b (address = csiop + offset 0bh) note: 1 = current state of imc is logic '1,' 0 = current state is logic ?0? table 119. input macrocell port c (address = csiop + offset 18h) note: 1. x = not guaranteed value, can be read either '1' or '0.' these are jtag pins. 2. 1 = current state of imc is logic '1,' 0 = current state is logic ?0? bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 i m c pa 7 i m c pa 6 i m c pa 5 i m c pa 4 i m c pa 3 i m c pa 2 i m c pa 1 i m c pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 imc pb7 imc pb6 imc pb5 imc pb4 imc pb3 imc pb2 imc pb1 imc pb0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 imc pc7 x x imc pc4 imc pc3 imc pc2 x x input macrocell (imc) d q g d q m u x m u x psdsoft 8032 data bit 8032 read of particular csiop imc register pt clock or gate (.ld or .le) pin input latched input gated input (.ld) (.le) ale psdsoft ale 8032 addr, data, cntl bus from i/o port logic input signal from pin on port a, b, or c from and-or array to pld input bus this sigal is ganged to 3 other imcs, grouping imc 0 - 3 or imc 4 - 7. ai06603a
199/264 upsd34xx - psd module i/o ports. there are four programmable i/o ports on the psd module: port a (80-pin device only), port b, port c, and port d. ports a and b are eight bits each, port c is four bits, and port d is two bits for 80-pin devices or 1-bit for 52-pin devices. each port pin is individually configurable, thus allowing multiple functions per port. the ports are config- ured using psdsoft express then programming with jtag, and also by the 8032 writing to csiop registers at run-time. topics discussed in this section are: general port architecture port operating modes individual port structure general port architecture. the general archi- tecture for a single i/o port pin is shown in figure 80., page 200 . port structures for ports a, b, c, and d differ slightly and are shown in figure 85., page 212 though figure 88., page 217 . figure 80., page 200 shows four csiop registers whose outputs are determined by the value that the 8032 writes to csiop direction, drive, control, and data out. the i/o port logic contains an out- put mux whose mux select signal is determined by psdsoft express and the csiop control register bits at run-time. inputs to this output mux include the following: 1. data from the csiop data out register for mcu i/o output mode (all ports) 2. latched de-multiplexed 8032 address for address output mode (ports a and b only) 3. peripheral i/o mode data bit (port a only) 4. gpld omc output (ports a, b, and c). the port data buffer (pdb) provides feedback to the 8032 and allows only one source at a time to be read when the 8032 reads various csiop regis- ters. there is one pdb for each port pin enabling the 8032 to read the following on a pin-by-pin ba- sis: 1. mcu i/o signal direction setting (csiop direction reg) 2. pin drive type setting (csiop drive select reg) 3. latched addr out mode setting (csiop control reg) 4. mcu i/o pin output setting (csiop data out reg) 5. output enable of pin driver (csiop enable out reg) 6. mcu i/o pin input (csiop data in reg) a port pin?s output enable signal is controlled by a two input or gate whose inputs come from: a product term of the and-or array; the output of the csiop direction register. if an output enable from the and-or array is not defined, and the port pin is not defined as an omc output, and if peripheral i/o mode is not used, then the csiop di- rection register has sole control of the oe signal. as shown in figure 80., page 200 , a physical port pin is connected to the i/o port logic and is also separately routed to an imc, allowing the 8032 to read a port pin by two different methods (mcu i/o input mode or read the imc). port operating modes. i/o port logic has sever- al modes of operation. table 115., page 197 sum- marizes which modes are available on each port. each of the port operating modes are described in following sections. some operating modes can be defined using psdsoft express, and some by the 8032 writing to the csiop registers at run-time, and some require both. for example, pld i/o, latched address out, and peripheral i/o modes must be defined in psdsoft express and programmed into the device using jtag, but an additional step must happen at run-time to activate latched ad- dress out mode and peripheral i/o mode, but not needed for pld i/o. in another example, mcu i/o mode is controlled completely by the 8032 at run- time and only a simple pin name declaration is needed in psdsoft express for documentation. table 116., page 197 summarizes what actions are needed in psdsoft express and what actions are required by the 8032 at run-time to achieve the various port functions.
upsd34xx - psd module 200/264 figure 80. detail of a single i/o port (typical of ports a, b, c) i/o port logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) d bit, periph i/o mode, port a pt output enable (.oe) latched addr bit, port a or b oe mux 8032 data bit output driver typical pin port a, b, c psd module reset one of 6 csiop registers output select peripheral i/o mode sets direction (port a only) 8032 address, data, control bus 1 2 3 4 1 2 3 4 5 6 from omc output to imc from pld input bus from and-or array from omc allocator d clr direction drive control (mcui/o) data out reset psdsoft pselx periph i/o data bit csiop regis- ters q q q q drive type 8032 data bits input buffer output enable wr rd pio en 8032 wr 8032 rd ai07873a
201/264 upsd34xx - psd module table 120. port operating modes note: 1. mcellbc outputs available only on pins pc2, pc3, pc4, and pc7. 2. jtag pins (pc0/tms, pc1/tck, pc5/tdi, pc6/tdo) are dedicated to jtag pin functions (cannot be used for general i/o). port operating mode port a (80-pin only) port b port c port d find it m c u i / o ye s ye s ye s ye s mcu i/o mode., p age 203 pld i/o omc mcellab outputs omc mcellbc outputs external chip-select outputs pld inputs ye s no no ye s ye s ye s no ye s no ye s (1) no ye s no no ye s ye s pld i/o mode., p age 205 latched address output yes yes no no latched address output mode, pa ge 208 peripheral i/o mode yes no no no peripher al i/o mode, pa ge 209 jtag isp no no ye s (2) no jtag isp mode., p age 210
upsd34xx - psd module 202/264 table 121. port configuration setting requirements port operating mode required action in psdsoft express to configure each pin value that 8032 writes to csiop control register at run-time value that 8032 writes to csiop direction register at run-time value that 8032 writes to bit 7 (pio_en) of csiop vm register at run-time mcu i/o choose the mcu i/o function and declare the pin name logic '0' (default) logic 1 = out of upsd logic 0 = into upsd n/a pld i/o choose the pld function type, declare pin name, and specify logic equation(s) n/a direction register has no effect on a pin if pin is driven from omc output n/a latched address output choose latched address out function, declare pin name logic '1' logic '1' only n/a peripheral i/o choose peripheral i/o mode function and specify address range in dpld for pselx n/a n/a pio_en bit = logic 1 (default is '0') 4-pin jtag isp no action required in psdsoft to get 4-pin jtag. by default tdo, tdi, tck, tms are dedicated jtag functions. n/a n/a n/a 6-pin jtag isp (faster programming) choose jtag tstat function for pin pc3 and jtag terr function for pin pc4. n/a n/a n/a
203/264 upsd34xx - psd module mcu i/o mode. in mcu i/o mode, the 8032 on the mcu module expands its own i/o by using the i/o ports on the psd module. the 8032 can read psd module i/o pins, set the direction of the i/o pins, and change the output state of i/o pins by ac- cessing the data in, direction, and data out csiop registers respectively at run-time. to implement mcu i/o mode, each desired pin is specified in psdsoft express as mcu i/o function and given a pin name. then 8032 firmware is writ- ten to set the direction bit for each corresponding pin during initialization routines (0 = in, 1 = out of the chip), then the 8032 firmware simply reads the corresponding data in register to determine the state of an i/o pin, or writes to a data out register to set the state of a pin. the direction of each pin may be changed dynamically by the 8032 if de- sired. a mixture of input and output pins within a single port is allowed. figure 80., page 200 shows the data in, data out, and direction signal paths. the data in registers are defined in table 122 to table 125 . the data out registers are defined in table 126 to table 129., page 204 . the direction registers are defined in table 130 to table 133., page 204 . table 122. mcu i/o mode port a data in register (1) (address = csiop + offset 00h) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 123. mcu i/o mode port b data in register (address = csiop + offset 01h) note: for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 124. mcu i/o mode port c data in register (address = csiop + offset 10h) note: 1. x = not guaranteed value, can be read either '1' or '0.' 2. for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 125. mcu i/o mode port d data in register (address = csiop + offset 11h) note: 1. x = not guaranteed value, can be read either '1' or '0.' 2. for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? 3. not available on 52-pin upsd34xx devices table 126. mcu i/o mode port a data out register (1) (address = csiop + offset 04h) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 3. default state of register is 00h after reset or power-up table 127. mcu i/o mode port b data out register (address = csiop + offset 05h) note: 1. for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2. default state of register is 00h after reset or power-up bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 x x pc4 pc3 pc2 x x bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 xxxxx pd2 (3) pd1 x bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0
upsd34xx - psd module 204/264 table 128. mcu i/o mode port c data out register (address = csiop + offset 12h) note: 1. for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2. default state of register is 00h after reset or power-up table 129. mcu i/o mode port d data out register (address = csiop + offset 13h) note: 1. for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2. default state for register is 00h after reset or power-up 3. not available on 52-pin upsd34xx devices table 130. mcu i/o mode port a direction register (1) (address = csiop + offset 06h) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 3. default state for register is 00h after reset or power-up table 131. mcu i/o mode port b direction in register (address = csiop + offset 07h) note: 1. for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2. default state for register is 00h after reset or power-up table 132. mcu i/o mode port c direction register (address = csiop + offset 14h) note: 1. for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2. default state for register is 00h after reset or power-up table 133. mcu i/o mode port d direction register (address = csiop + offset 15h) note: 1. for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2. default state for register is 00h after reset or power-up 3. not available on 52-pin upsd34xx devices bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 n/a n/a pc4 pc3 pc2 n/a n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) pd1 n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 n/a n/a pc4 pc3 pc2 n/a n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) pd1 n/a
205/264 upsd34xx - psd module pld i/o mode. pins on ports a, b, c, and d can serve as inputs to either the dpld or the gpld. inputs to these plds from ports a, b, and c are routed through imcs before reaching the pld in- put bus. inputs to the plds from port d do not pass through imcs, but route directly to the pld input bus. pins on ports a, b, and c can serve as outputs from gpld omcs, and port d pins can be outputs from the dpld (external chip-selects) which do not consume omcs. whenever a pin is specified to be a pld output, it cannot be used for mcu i/o mode, or other pin modes. if a pin is specifie d to be a pld input, it is still possible to read the pin using mcu i/o input mode with the csiop register data in. also, the csiop direction register ca n still affect a pin which is used for a pld input. the csiop data out regis- ter has no effect on a pld output pin. each pin on ports a, b, c, and d have a tri-state buffer at the final output stage. the output enable signal for this buffer is driven by the logical or of two signals. one signal is an output enable signal generated by the and-or array (from an .oe equation specified in psdsoft), and the other sig- nal is the output of the csiop direction register. this logic is shown in figure 80., page 200 . at power-on, all port pins default to high-impedance input (direction registers default to 00h). however, if an equation is written for the output enable that is active at power-on, then the pin will behave as an output. pld i/o equations are specified in psdsoft ex- press and programmed into the upsd using jtag. figure 81 shows a very simple combinato- rial logic example which is implemented on pins of port b. to give a general idea of how pld logic is imple- mented using psdsoft express, figure 82., page 206 illustrates the pin declaration win- dow of psdsoft express, showing the pld output at pin pb0 declared as ?combinatorial? in the ?pld output? section, and a signal name, ?pld_out?, is specified. the other three signals on pins pb1, pb2, and pb3 would be declared as ?logic or ad- dress? in the ?pld input? section, and given signal names. in the ?design assistant? window of psdsoft ex- press shown in figure 83., page 207 , the user simply enters the logic equation for the signal ?pld_out? as shown. the user can either type in the logic statements or enter them using a point-and- click method, selecting various signal names and logic operators available in the window. after psdsoft express has accepted and realized the logic from the equations, it synthesizes the log- ic statement: pld_out = ( pld_in_1 # pld_in_2 ) & !pld_in_3; to be programmed into the gpld. see the psd- soft user?s manual for all the steps. note: if a particular omc output is specified as an internal node and not specified as a port pin output in psdsoft express, then the port pin that is asso- ciated with that omc can be used for other i/o functions. figure 81. simple pld logic example pldin 1 pldin 2 pldin 3 pld out pb0 pb3 pb2 pb1 ai09178
upsd34xx - psd module 206/264 figure 82. pin declarations in psdso ft express for simple pld example
207/264 upsd34xx - psd module figure 83. using the design assistant in psdsoft express for simple pld example
upsd34xx - psd module 208/264 latched address output mode. in the mcu module, the data bus bits d0-d15 are multiplexed with the address bits a0-a15, and the ale signal is used to separate them with respect to time. sometimes it is necessary to send de-multiplexed address signals to external peripherals or memory devices. latched address output mode will drive individual demuxed address signals on pins of ports a or b. port pins can be designated for this function on a pin-by-pin basis, meaning that an en- tire port will not be sacrific ed if only a few address signals are needed. to activate this mode, the desired pins on port a or port b are designated as ?latched address out? in psdsoft. then in the 8032 initialization firm- ware, a logic ?1? is writte n to the csiop control reg- ister for port a or port b in each bit position that corresponds to the pin of the port driving an ad- dress signal. table 134 and table 135 define the csiop control register locations and bit assign- ments. the latched low address byte a4-a7 is available on both port a and port b. the high address byte a8-a15 is available on port b only. selection of high or low address byte is specified in psdsoft express. table 134. latched address output, port a control register (1) (address = csiop + offset 02h) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = drive demuxed 8032 address signal on pin, 0 = pin is default mode, mcu i/o 3. default state for register is 00h after reset or power-up table 135. latched address output, port b control register (address = csiop + offset 03h) note: 1. for each bit, 1 = drive demuxed 8032 address signal on pin, 0 = pin is default mode, mcu i/o 2. default state for register is 00h after reset or power-up bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 (addr a7) pa 6 (addr a6) pa 5 (addr a5) pa 4 (addr a4) pa 3 (addr a3) pa 2 (addr a2) pa 1 (addr a1) pa 0 (addr a0) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 (addr a7 or a15) pb6 (addr a6 or a14) pb5 (addr a5 or a13) pb4 (addr a4 or a12) pb3 (addr a3 or a11) pb2 (addr a2 or a10) pb1 (addr a1 or a9) pb0 (addr a0 or a8)
209/264 upsd34xx - psd module peripheral i/o mode. this mode will provide a data bus repeater function for the 8032 to interface with external parallel peripherals. the mode is only available on port a (80-pin devices only) and the data bus signals, d0 - d7, are de-multiplexed (no address a0-a7). when active, this mode be- haves like a bidirectional buffer, with the direction automatically controlled by the 8032 rd and wr signals for a specified address range. the dpld signals psel0 and psel1 determine this address range. figure 80., page 200 shows the action of peripheral i/o mode on the output enable logic of the tri-state output driver for a single port pin. fig- ure 84., page 209 illustrates data repeater the op- eration. to activate this mode, choose the pin function ?peripheral i/o mode? in psdsoft express on any port a pin (all eight pins of port a will auto- matically change to this mode). next in psdsoft, specify an address range for the pselx signals in the ?chip-select? section of the ?design assistant?. the user can specify an address range for either psel0 or psel1. always qualify the pselx equa- tion with ?psen is logic '1'? to ensure peripheral i/ o mode is only active during 8032 data cycles, not code cycles. only one equation is needed since pselx signals are or? ed together (figure 84 ). then in the 8032 initializat ion firmware, a logic ?1? is written to the csiop vm register, bit 7 (pio_en) as shown in table 99., page 163 . after this, port a will automatically perform this repeater function whenever the 8032 presents an address (and memory page number, if paging is used) that is within the range specified by pselx. once port a is designated as peripheral i/o mode in psdsoft express, it cannot be used for other functions. note: the user can alternatively connect an exter- nal parallel peripheral to the standard 8032 ad0- ad7 pins on an 80-pin upsd device (not port a), but these pins have multiplexed address and data signals, with a weaker f anout drive capability. figure 84. peripheral i/o mode psel1 port a pins pa0 - pa7 psel0 vm register bit 7 (pio en) 8032 rd 8032 wr 8032 data bus d0-d7 (de-muxed) 8 8 ai02886a
upsd34xx - psd module 210/264 jtag isp mode. four of the pins on port c are based on the ieee 1149.1 jtag specification and are used for in-system programming (isp) of the psd module and debugging of the 8032 mcu module. these pins (tdi, tdo, tms, tck) are dedicated to jtag and cannot be used for any other i/o function. there are two optional pins on port c (tstat and terr ) that can be used to re- duce programming time during isp. see jtag isp and jtag debug, page 226 . other port capabilities. it is possible to change the type of output drive on the ports at run-time. it is also possible to read the state of the output en- able signal of the output driver at run-time. the fol- lowing sections provide the details. port pin drive options. the csiop drive select registers allow reconfiguration of the output drive type for certain pins on ports a, b, c, and d. the 8032 can change the default drive type setting at run-time. the is no action needed in psdsoft ex- press to change or define these pin output drive types. figure 80., page 200 shows the csiop drive select register output controlling the pin output driver. the default setting for drive type for all pins on ports a, b, c, and d is a standard cmos push- pull output driver. note: when a pin on port a, b, c, d is not used as an output and has no external device driving it as an input (floating pin), excess power consumption can be avoided by placing a weak pull-up resistor (100k ? ) to v dd which keeps the cmos input pin from floating. drive select registers. the csiop drive select registers will configure a pin output driver as open drain or cmos push/pull for some port pins, and controls the slew rate for other port pins. an external pull-up resistor should be used for pins configured as open drain, and the resistor should be sized not to exceed th e current sink capability of the pin (see dc specifications). open drain out- puts are diode clamped, thus the maximum volt- age on an pin configured as open drain is v dd + 0.7v. a pin can be configured as open drain if its corre- sponding bit in the drive select register is set to logic '1.' note: the slew rate is a measurement of the rise and fall times of an output. a higher slew rate means a faster output response and may create more electrical noise. a pin operates in a high slew rate when the corresponding bit in the drive reg- ister is set to '1.' the default rate is standard slew rate (see ac specifications). table 136 through table 139., page 211 show the csiop drive registers for po rts a, b, c, and d. the tables summarize which pins can be configured as open drain outputs and which pins the slew rate can be changed. the default output type is cmos push/pull output with normal slew rate. enable out registers. the state of the output enable signal for the output driver at each pin on ports a, b, c, and d can be read at any time by the 8032 when it reads the csiop enable output regis- ters. logic '1' means the driver is in output mode, logic ?0? means the output driver is in high-imped- ance mode, making the pin suitable for input mode (read by the input buffer shown in figure 80., page 200 ). figure 80 shows the three sources that can control the pin output enable signal: a product term from and-or array; the csiop direc- tion register; or the peripheral i/o mode logic (port a only). the csiop enable out registers represent the state of the final output enable signal for each port pin driver, and are defined in table 140., page 211 through table 143., page 211 . table 136. port a pin drive select register (1) (address = csiop + offset 08h) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 3. default state for register is 00h after reset or power-up table 137. port b pin drive select register (address = csiop + offset 09h) note: 1. for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2. default state for register is 00h after reset or power-up bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 open drain pa 6 open drain pa 5 open drain pa 4 open drain pa 3 slew rate pa 2 slew rate pa 1 slew rate pa 0 slew rate bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 open drain pb6 open drain pb5 open drain pb4 open drain pb3 slew rate pb2 slew rate pb1 slew rate pb0 slew rate
211/264 upsd34xx - psd module table 138. port c pin drive select register (address = csiop + offset 16h) note: 1. for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2. default state for register is 00h after reset or power-up table 139. port d pin drive select register (address = csiop + offset 17h) note: 1. for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2. default state for register is 00h after reset or power-up 3. pin is not available on 52-pin upsd34xx devices table 140. port a enable out register (1) (address = csiop + offset 0ch) note: 1. port a not available on 52-pin upsd34xx devices 2. for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 141. port b enable out register (address = csiop + offset 0dh) note: for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 142. port c enable out register (address = csiop + offset 1ah) note: 1. for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 143. port d enable out register (address = csiop + offset 1bh) note: 1. for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) 2. pin is not available on 52-pin upsd34xx devices bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 open drain n/a (jtag) n/a (jtag) pc4 open drain pc3 open drain pc2 open drain n/a (jtag) n/a (jtag) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) slew rate pd1 slew rate n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa7 oe pa6 oe pa5 oe pa4 oe pa3 oe pa2 oe pa1 oe pa0 oe bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 oe pb6 oe pb5 oe pb4 oe pb3 oe pb2 oe pb1 oe pb0 oe bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 oe n/a (jtag) n/a (jtag) pc4 oe pc3 oe pc2 oe n/a (jtag) n/a (jtag) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 oe (2) pd1 oe n/a
upsd34xx - psd module 212/264 individual port structures. ports a, b, c, and d have some differences. the structure of each indi- vidual port is described in the next sections. port a structure. port a supports the following operating modes: mcu i/o mode gpld output mode from output macrocells mcellabx gpld input mode to input macrocells imcax latched address output mode peripheral i/o mode port a also supports open drain/slew rate output drive type options using csiop drive select regis- ters. pins pa0-pa3 can be configured to fast slew rate, pins pa4-pa7 can be configured to open drain mode. see figure 85 for details. figure 85. port a structure note: 1. port pins pa0-pa3 are capable of fast slew rate output drive option. port pins pa4-pa7 are capable of open drain output option. i/o port a logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) d bit, periph i/o mode pt output enable (.oe) latched addr bit oe mux output enable typical pin, port a psd module reset one of 6 csiop registers output select peripheral i/o mode sets direction 8032 address, data, control bus 1 2 3 4 1 2 3 4 5 6 from omc output (mcellabx) from pld input bus from and- or array from omc allocator d clr direction drive control (mcui/o) data out 8032 wr reset psdsoft 8032 rd pselx wr rd periph i/o data bit to imcs pio en csiop regis- ters q q q q drive type select (1) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = open drain, pa4 - pa7 1 = fast slew rate, pa0 - pa3 imca0 - imca7 ai09179
213/264 upsd34xx - psd module port b structure. port b supports the following operating modes: mcu i/o mode gpld output mode from output macrocells mcellabx, or mcellbcx (omc allocator routes these signals) gpld input mode to input macrocells imcbx latched address output mode port b also supports open drain/slew rate output drive type options using the csiop drive select reg- isters. pins pb0-pb3 can be configured to fast slew rate, pins pb4-pb7 can be configured to open drain mode. see figure 86 for detail. figure 86. port b structure note: 1. port pins pb0-pb3 are capable of fast slew rate output drive option. port pins pb4-pb7 are capable of open drain output option. i/o port b logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) pt output enable (.oe) latched addr bit output enable output enable typical pin, port b psd module reset one of 6 csiop registers output select 8032 address, data, control bus 1 2 3 1 2 3 4 5 6 from omc output (mcellabx or mcellbcx) from pld input bus from and- or array from omc allocator d clr direction drive control (mcui/o) data out 8032 wr reset psdsoft 8032 rd to imcs csiop regis- ters q q q q drive type select (1) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = open drain, pb4 - pb7 1 = fast slew rate, pb0 - pb3 imcb0 - imcb7 ai09180
upsd34xx - psd module 214/264 port c structure. port c supports the following operating modes on pins pc2, pc3, pc4, pc7: mcu i/o mode gpld output mode from output macrocells mcellbc2, mcellbc3, mcellbc4, mcellbc7 gpld input mode to input macrocells imcc2, imcc3, imcc4, imcc7 see figure 87., page 215 for detail. port c pins can also be configured in psdsoft for other dedicated functions: ? pins pc3 and pc4 support tstat and terr status indicators, to reduce the amount of time required for jtag isp programming. these two pins must be used together for this function, adding to the four standard jtag signals. when tstat and terr are used, it is referred to as ?6-pin jtag?. pc3 and pc4 cannot be used for other functions if they are used for 6-pin jtag. see jtag isp and jtag debug, page 226 for details. ? pc2 can be used as a voltage input (from battery or other dc source) to backup the contents of sram when v dd is lost. this function is specified in psdsoft express as sram standby mode (battery backup), page 224 . ? pc3 can be used as an output to indicate when a flash memory program or erase operation has completed. this is specified in psdsoft express as ready/busy (pc3), page 184 . ? pc4 can be used as an output to indicate when the sram has switched to backup voltage (when v dd is less than the battery input voltage on pc2). this is specified in psdsoft express as ?s tandby-on indicator? (see sram standby mode (battery backup), page 224 ). the remaining four pins (tdi, tdo, tck, tms) on port c are dedicated to the jtag function and cannot be used for any other function. see jtag isp and jtag debug, page 226 . port c also supports the open drain output drive type options on pins pc2, pc3, pc4, and pc7 us- ing the csiop drive select registers.
215/264 upsd34xx - psd module figure 87. port c structure note: 1. pull-up switches to v bat when sram goes to battery back-up mode. 2. optional function on a specific port c pin. i/o port c logic o u t p u t m u x p d b m u x direction drive select data out (mcui/o) enable out data in (mcui/o) pt output enable, .oe (jtag state machine automatically controls oe for jtag signals) output enable typical pin, port c psd module reset one of 6 csiop registers 8032 address, data, control bus 1 2 3 4 5 1 2 3 4 5 from omc output (mcellbcx) standby on (2) from sram back-up circuit from flash memories to/from jtag state machine from pld input bus from and- or array from omc allocator d clr direction drive (mcui/o) data out 8032 wr reset psdsoft 8032 rd to imcs csiop regis- ters q q q drive type select (2) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd /v bat (1) v dd /v bat (1) pin output 50k pull-up only on jtag tdi, tms, tck signals to sram battery back-up circuit (2) imcc2, imcc3, imcc4, imcc7 rdy/bsy (2) tdo, tstat (2) , terr (2) tdi, tms, tck ai09181
upsd34xx - psd module 216/264 port d structure. port d has two i/o pins (pd1, pd2) on 80-pin upsd34xx devices, and just one pin (pd1) on 52-pin devices, supporting the follow- ing operating modes: mcu i/o mode dpld output mode for external chip selects, ecs1, ecs2. this does not consume omcs in the gpld. pld input mode ? direct input to the pld input bus available to dpld and gpld. does not use imcs see figure 88., page 217 for detail. port d pins can also be configured in psdsoft as pins for other dedicated functions: ? pd1 can be used as a common clock input to all 16 omc flip-flops (see omcs, page 167 ) and also the automatic power-down (apd), page 220 . ? pd2 can be used as a common chip select signal (csi ) for the flash and sram memories on the psd module (see chip se- lect input (csi), page 222 ). if driven to logic ?1? by an external source, csi will force all memories into standby mode regardless of what other internal memory select signals are doing on the psd module. this is specified in psdsoft as ?psd chip select input, csi ?. port d also supports the fast slew rate output drive type option using the csiop drive select reg- isters.
217/264 upsd34xx - psd module figure 88. port d structure note: 1. optional function on a specific port d pin. i/o port d logic o u t p u t m u x p d b m u x direction drive select data out (mcui/o) enable out data in (mcui/o) pt output enable (.oe) output enable output enable typical pin, port d psd module reset one of 5 csiop registers 8032 address, data, control bus 1 2 1 2 3 4 5 from dpld external chip (ecsx) from pld input bus from and- or array from dpld d clr direction drive (mcui/o) data out 8032 wr reset psdsoft 8032 rd to power management and pld input bus csiop regis- ters q q q drive type select 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = fast slew rate pd1. pin, pd2.pin directly to pld input bus, no imc csi (1) to power management clkin (1) ai09182
upsd34xx - psd module 218/264 power management. the psd module offers configurable power saving options, and also a way to manage power to the sram (battery backup). these options may be used individually or in com- binations. a top level description for these func- tions is given here, then more detailed descriptions will follow. ? zero-power memory: all memory arrays (flash and sram) in the psd module are built with zero-power technology, which puts the memories into standby mode (~ zero dc current) when 8032 address signals are not changing. as soon as a transition occurs on any address input, the affected memory ?wakes up?, changes and latches its outputs, then goes back to standby. the designer does not have to do anything special to achieve this memory standby mode when no inputs are changing?it happens automatically. thus, the slower the 8032 clock, the lower the current consumption. both plds (dpld and gpld) are also zero- power, but this is not the default condition. the 8032 must set a bit in one of the csiop pmmr registers at run-time to achieve zero-power. ? automatic power-down (apd): the apd feature allows the psd module to reach its lowest current consumptio n levels. if enabled, the apd counter will time-out when there is a lack of 8032 bus activity for an extended amount of time (8032 asleep). after time-out occurs, all 8032 address and data buffers on the psd module are shut down, preventing the psd module memories and potentially the plds from waking up from standby, even if address inputs are changing state because of noise or any external components driving the address lines. since the actual address and data buffers are turned off, current consumption is even further reduced. note: non-address signals are still available to pld inputs and will wake up the plds if these signals are changing state, but will not wake up the memories. the apd counter requires a relatively slow external clock input on pin pd1 that does stop when the 8032 goes to sleep mode. ? forced power-down (fpd): the mcu can put the psd module in to power-down mode with the same results as using apd described above, but fpd does not rely on the apd counter. inst ead, fpd will force the psd module into power-do wn mode when the mcu firmware sets a bit in one of the csiop pmmr registers. this is a good alternative to apd because no external clock is needed for the apd counter. ? psd module chip select input (csi ): this input on pin pd2 (80-pin devices only) can be used to disable the internal memories, placing them in standby mode even if address inputs are changing. this feature does not block any internal signals (the address and data buffers are still on but signals are ignored) and csi does not disable the plds. this is a good alternative to using the apd counter, which requires an external clock on pin pd1. ? non-turbo mode: the plds can operate in turbo or non-turbo modes. turbo mode has the shortest signal propagation delay, but consumes more current than non-turbo mode. a csiop register can be written by the 8032 to select modes, the default mode is with turbo mode enabled. in non-turbo mode, the plds can achieve very low standby current (~ zero dc current) while no pld inputs are changing, and the plds will even use less ac current when inputs do change compared to turbo mode. when the turbo mode is enabled, there is a significant dc current component and the ac current component is higher than non-turbo mode, as shown in figure 96., page 233 (5v) and figure 97., page 233 (3.3v). ? blocking bits: significant power savings can be achieved by blocking 8032 bus control signals (rd , wr , psen , ale) from reaching pld inputs, if these signals are not used in any pld equations. blocking is achieved by the 8032 writing to the ?blocking bits? in csiop pmmr registers. current consumption of the plds is directly rela ted to the composite frequency of all transitions on pld inputs, so blocking certain pld inputs can significantly lower pld operating frequency and power consumption (resulting in a lower frequency on the graphs of figure 96., page 233 and figure 97., page 233 ). ? sram backup voltage: pin pc2 can be configured in psdsoft to accept an alternate dc voltage source (battery) to automatically retain the contents of sram when v dd drops below this alternate voltage. note: it is recommended to prevent unused inputs from floating on ports a, b, c, and d by pulling them up to v dd with a weak external resistor (100k ? ), or by setting the csiop direction register to ?output? at run-time for all unused inputs. this will prevent the cmos input buffers of unused input pins from drawing excessive current. the csiop pmmr register definitions are shown in 144 through table 146., page 219 .
219/264 upsd34xx - psd module table 144. power management mode register pmmr0 (address = csiop + offset b0h) note: all the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. 1. blocking bits should be set to logic ?1? only if the signal is not needed in a dpld or gpld logic equation. table 145. power management mode register pmmr2 (address = csiop + offset b4h) note: the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. 1. blocking bits should be set to logic ?1? only if the signal is not needed in a dpld or gpld logic equation. table 146. power management mode register pmmr3 (address = csiop + offset c7h) note: the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. bit 0 x 0 not used, and should be set to zero. bit 1 apd enable 0 automatic power down (apd) counter is disabled. 1 apd counter is enabled bit 2 x 0 not used, and should be set to zero. bit 3 pld turbo disable 0 = on pld turbo mode is on 1 = off pld turbo mode is off, saving power. bit 4 blocking bit, clkin to plds (1) 0 = on clkin (pin pd1) to the pld input bus is not blocked. every transition of clkin powers-up the plds. 1 = off clkin input to pld input bus is blocked, saving power. but clkin still goes to apd counter. bit 5 blocking bit, clkin to omcs only (1) 0 = on clkin input is not blocked from reaching all omcs? common clock inputs. 1 = off clkin input to common clock of all omcs is blocked, saving power. but clkin still goes to apd counter and all pld logic bes ides the common clock input on omcs. bit 6 x 0 not used, and should be set to zero. bit 7 x 0 not used, and should be set to zero. bit 0 x 0 not used, and should be set to zero. bit 1 x 0 not used, and should be set to zero. bit 2 blocking bit, wr to plds (1) 0 = on 8032 wr input to the pld input bus is not blocked. 1 = off 8032 wr input to pld input bus is blocked, saving power. bit 3 blocking bit, rd to plds (1) 0 = on 8032 rd input to the pld input bus is not blocked. 1 = off 8032 rd input to pld input bus is blocked, saving power. bit 4 blocking bit, psen to plds (1) 0 = on 8032 psen input to the pld input bus is not blocked. 1 = off 8032 psen input to pld input bus is blocked, saving power. bit 5 blocking bit, ale to plds (1) 0 = on 8032 ale input to the pl d input bus is not blocked. 1 = off 8032 ale input to pld input bus is blocked, saving power. bit 5 blocking bit, pc7 to plds (1) 0 = on pin pc7 input to the pld input bus is not blocked. 1 = off pin pc7 input to pld input bus is blocked, saving power. bit 7 x 0 not used, and should be set to zero. bit 0 x 0 not used, and should be set to zero. bit 1 force_pd 0 = off apd counter will cause power-down mode if apd is enabled. 1 = on power-down mode will be entered immediately regardles s of apd activity. bit 3-7 x 0 not used, and should be set to zero.
upsd34xx - psd module 220/264 automatic power-down (apd). the apd unit shown in figure 74., page 188 puts the psd mod- ule into power-down mode by monitoring the activ- ity of the 8032 address latch enable (ale) signal. if the apd unit is enabled by writing a logic ?1? to bit 1 of the csiop pmmr0 register, and if ale sig- nal activity has stopped (8032 in sleep mode), then the four-bit apd counter starts counting up. if the ale signal remains inactive for 15 clock peri- ods of the clkin signal (pin pd1), then the apd counter will reach maximu m count and the power down indicator signal (pdn) goes to logic ?1? forc- ing the psd module into power-down mode. dur- ing this time, all buffers on the psd module for 8032 address and data signals are disabled in sil- icon, preventing the psd module memories from waking up from stand-by mode, even if noise or other devices are driving the address lines. the plds will also stay in standby mode if the plds are in non-turbo mode and if all other pld inputs (non-address signals) are static. however, if the ale signal has a transition before the apd counter reaches max count, the apd counter is cleared to zero and the pdn signal will not go active, preventing power-down mode. to prevent unwanted apd time-outs during normal 8032 operation (not sleeping), it is important to choose a clock frequency for clkin that will not produce 15 or more pulses within the longest peri- od between ale transitions. a 32768 hz clock sig- nal is quite often an ideal frequency for clkin and apd, and this frequency is often available on ex- ternal supervisor or real-time clock devices. the ?pdn? power-down indicator signal is avail- able to the pld input bus to use in any pld equa- tions if desired. the user may want to send this signal as a pld output to an external device to in- dicate the psd module is in power-down mode. psdsoft express automatically includes the ?pdn? signal in the dpld chip select equations for fsx, csbootx, rs0, and csiop. the following should be kept in mind when the psd module is in power-down mode: ? 8032 address and data bus signals are blocked from all memories and both plds. ? the psd module comes out of power-down mode when: ale starts pulsing again, or the csi input on pin pd2 transitions from logic ?1? to logic '0,' or the psd module reset signal, rst , transitions from logic ?0? to logic '1.' ? various signals can be blocked (prior to power-down mode) from entering the plds by using ?blocking bits? in csiop pmmr registers. ? all memories enter standby mode, and the state of the plds and i/o ports are unchanged (if no pld inputs change). table 148., page 225 shows the effects of power- down mode on i/o pins while in various operating modes. ? the 8032 ports 1,3, and 4 on the mcu module are not affected at all by power-down mode in the psd module. ? power-down standby current given in the ac specifications for psd module assume there are no transitions on any unblocked pld input, and there are no output pins driving any loads. the apd counter will count whenever bit 1 of csiop pmmr0 register is set to logic '1,' and when the ale signal is steady at either logic ?1? or logic ?0? (not transitioning). figure 90., page 222 shows the flow leading up to power-down mode. the only action required in psdsoft express to enable apd mode is to select the pin function ?common clock input, clkin? before programming with jtag.
221/264 upsd34xx - psd module forced power down (fdp). an alternative to apd is fpd. the resulting power-savings is the same, but the pdn signal in figure 89., page 222 is set and power-down mode is entered immedi- ately when firmware sets the force_pd bit to logic '1' in the csiop register pmmr3 (bit 1). fpd will override apd c ounter activity when force_pd is set. no external clock source for the apd counter is needed. the force_pd bit is cleared only by a reset condition. caution must be used when implementing fpd because code memory goes off-line as soon as psd module power-down mode is entered, leav- ing the mcu with no instruction stream to execute. the mcu module must put itself into power-down mode after it puts the psd module into power- down mode. how can it do this if code memory goes off-line? the answer is the pre-fetch queue (pfq) in the mcu module. by using the instruction scheme shown in the 8051 assembly code exam- ple in table 147 , the pfq will be loaded with the final instructions to command the mcu module to power down mode after the pds module goes to power-down mode. in this case, even though the code memory goes off-line in the psd module, the last few mcu instructio n are sourced from the pfq. table 147. forced power-down example pdown: anl a8h, #7fh ; disable all interrupts orl 9dh, #c0h ; ensure pfq and bc are enabled mov dptr, #xxc7 ; load xdata pointer to select pmmr3 register (xx = base ; address of csiop registers) clr a ; clear a jmp loop ; first loop - fill pfq/bq with power down instructions nop ; second loop - fetch code from pfq/bc and set power- ; down bits for psd module and then mcu module loop: movx @dptr, a ; set force_pd bit in pmmr3 in psd module in second ; loop mov 87h, a ; set pd bit in pcon register in mcu module in second ; loop mov a, #02h ; set power-down bit in the a register, but not in pmmr3 or ; pcon yet in first loop jmp loop ; upsd enters into power-down mode in second loop
upsd34xx - psd module 222/264 figure 89. automatic power down (apd) unit figure 90. power-down mode flow chart chip select input (csi ). pin pd2 of port d can optionally be configured in psdsoft express as the psd module chip se lect input, csi , which is an active-low logic input. by default, pin pd2 does not have the csi function. when the csi function is specified in psdsoft ex- press, the csi signal is automatically included in dpld chip select equations for fsx, csbootx, rs0, and csiop. when the csi pin is driven to logic ?0? from an external device, all of these mem- ories will be available fo r read and write oper- ations. when csi is driven to logic '1,' none of these memories are available for selection, re- gardless of the address activity from the 8032, re- ducing power consumption. the state of the pld and port i/o pins are not changed when csi goes to logic ?1? (disabled). pmmr0, bit 1 (apd en) 8032 ale psd module rst_ csi (pin pd2) clkin (pin pd1) pdn omc outputs fsx csbootx rs0 csiop 8032 data from mcu module 8032 addr from mcu module pdn pdn csi pmmr3, bit 1 (force_pd) enable 1 = found transition 1 = found edge clear full count dpld chip select equations gpld transition detection edge detection 4-bit apd up-counter enable clk 1 = power down mode enable psd module line buffers 8032 data 8032 addr when csi function is specified in psdsoft express, csi is part of equations for fsx, csbootx, rs0, and csiop ai06608b enable apd. set pmmr0, bit 1 = 1 reset optional . disable desired inputs to plds by setting pmmr0 bits 4 and 5, and pmmr2 bits 2 through 6 ale idle for 15 clkin clocks? pdn = 1, psd module in power- down mode yes no ai09183
223/264 upsd34xx - psd module pld non-turbo mode. the power consumption and speed of the plds are controlled by the turbo bit (bit 3) in the csiop pmmr0 register. by setting this bit to logic '1,' the turbo mode is turned off and both plds consume only stand-by current when all pld inputs have no transitions for an extend- ed time (65ns for 5v devices, 100ns for 3.3 v de- vices), significantly redu cing current consumption. the plds will latch their out puts and go to stand- by, drawing very little current. when turbo mode is off, pld propagation delay time is increased as shown in the ac specifications for the psd mod- ule. since this additional propagation delay also effects the dpld, the response time of the memo- ries on the psd module is also lengthened by that same amount of time. if turbo mode is off, the user should add an additional wait state to the 8032 buscon sfr register if the 8032 clock fre- quency is higher that a particular value. please re- fer to table 38., page 66 in the mcu module section. the default state of the turbo bit is logic '0,' mean- ing turbo mode is on by default (after power-up and reset conditions ) until it is turned off by the 8032 writing to pmmr0. pld current consumption. figure 96., page 233 and figure 97., page 233 (5v and 3.3v devices respectively ) show the relationship between pld current consumption and the com- posite frequency of all the transitions on pld in- puts, indicating that a higher input frequency results in higher current consumption. current consumption of the plds have a dc com- ponent and an ac component. both need to be considered when calculating current consumption for a specific pld design. when turbo mode is on, there is a linear relationship between current and frequency, and there is a substantial dc current component consumed by the psd module when there are no transitions on pld inputs (composite frequency is zero). the magnitude of this dc cur- rent component is directly proportional to how many product terms are used in the equations of both plds. psdsoft express generates a ?fitter? report that specifies how many product terms were used in a design out of a total of 186 available product terms. figure 96., page 233 and figure 97., page 233 both give two examples, one with 100% of the 186 product terms used, and another with 25% of the 186 product terms used. turbo mode current consumption. to deter- mine the ac current component of the specific pld design with turbo mode on, the user will have to interpolate from the graph, given the number of product terms specified in the fitter report, and the estimated composite frequency of pld input sig- nal transitions. for th e dc component (y-axis crossing), the user can calculate the number by multiplying the number of product terms used (from fitter report) times the dc current per prod- uct term specified in the dc specifications for the psd module. the total pld current usage is the sum of its ac and dc components. non-turbo mode current consumption. no- tice in figure 96., page 233 and figure 97., page 233 that when turbo mode is off, the dc current consumption is ?zero? (just standby cur- rent) when the composite frequency of pld input transitions is zero (no input transitions). now mov- ing up the frequency axis to consider the ac cur- rent component, current consumption remains considerably less than tu rbo mode until pld input transitions happen so rapidly that the plds do not have time to latch their outputs and go to standby between the transitions anymore. this is where the lines converge on the graphs, and current con- sumption becomes the same for pld input transi- tions at this frequency and higher regardless if turbo mode is on or off. to determine the current consumption of the plds with turbo mode off, ex- trapolate the ac component from the graph based on number of product terms and input frequency. the only dc component in non-turbo mode is the psd module standby current. the key to reducing pld current consumption is to reduce the composite frequency of transitions on the pld input bus, moving down the frequency scale on the graphs. one way to do this is to care- fully select which signals are entering pld inputs, not selecting high frequency signals if they are not used in pld equations. another way is to use pld ?blocking bits? to block certain signals from enter- ing the pld input bus.
upsd34xx - psd module 224/264 pld blocking bits. blocking specific signals from entering the plds using bits of the csiop pmmr registers can further reduce pld ac cur- rent consumption by lowering the effective com- posite frequency of inputs to the plds. blocking 8032 bus control signals. when the 8032 is active on the mcu module, four bus con- trol signals (rd , wr , psen , and ale) are con- stantly transitioning to manage 8032 bus traffic. each time one of these signals has a transition from logic ?1? to '0,' or 0 to '1,' it will wake up the plds if operating in non-turbo mode, or when in turbo mode it will cause the affected pld gates to draw current. if equations in the dpld or gpld do not use the signals rd , wr , psen , or ale then these signals can be blo cked which will reduce the ac current component substantially. these bus control signals are rarely used in dpld equations because they are routed in silicon directly to the memory arrays of the psd module, bypassing the plds. for example, it is not necessary to qualify a memory chip select signal with an mcu write strobe, such as ?fs0 = address range & !wr_?. only ?fs0 = address range? is needed. each of the 8032 bus control signals may be blocked individually by writing to bits 2, 3, 4, and 5 of the pmmr2 register shown in table 145., page 219 . blocking any of these four bus control signals only prevents them from reaching the plds, but they will always go to the memories directly. however, sometimes it is necessary to use these 8032 bus control signals in the gpld when creat- ing interface signals to external i/o peripherals. but it is still possible to save power by dynamically unblocking the bus signals before reading/writing the external device, then blocking the signals after the communication is complete. the user can also block an input signal coming from pin pc7 to the pld input bus if desired by writing to bit 6 of pmmr2. blocking common clock, clkin. the input clkin (from pin pd1) can be blocked to reduce current consumption. clkin is used as a common clock input to all omc flip-f lips, it is a general input to the pld input bus, and it is used to clock the apd counter. in psdsoft express, the function of pin pd1 must be specified as ?common clock in- put, clkin? before programming the device with jtag to get the clkin function. bit 4 of pmmr0 can be set to logic ?1? to block clkin from reaching the pld input bus, but clkin will still reach the apd counter. bit 5 of pmmr0 can be set to logic ?1? to block clkin from reaching the omc flip-flops only, but clkin is still available to the pld input bus and the apd counter. see table 144., page 219 for details. sram standby mode (battery backup). the sram on the psd module may optionally be backed up by an external battery (or other dc source) to make its conten ts non-volatile. this is achieved by connecting a battery to pin pc2 on port c and selecting the ?sram standby? function for pin pc2 within psdsoft express. automatic voltage supply cross-over circuitry is built into the psd module to switch sram supply to battery as soon as v dd drops below the voltage level of the battery. sram contents are protected while bat- tery voltage is greater than 2.0v. pin pc4 on port c can be used as an output to indicate that a bat- tery switch-over has occurred. this is configured in psdsoft express by selecting the ?standby on indicator? option for pin pc4. psd module reset conditions the psd module receives a reset signal from the mcu module. this reset signal is referred to as the ?rst ? input in psd module documentation, and it is active-low when asserted. the character of the rst signal generated from the mcu module is de- scribed in supervisory functions, page 67 . upon power-up, and while rst is asserted, the psd module immediately loads its configuration from non-volatile bits to configure the plds and other items. pld logic is operational and ready for use well before rst is de-asserted. the state of pld outputs are determined by equations speci- fied in psdsoft express. the flash memories are reset to read array mode after any assertion of rst (even if a pro- gram or erase operation is occurring). flash memory write operations are automatical- ly prevented while v dd is ramping up until it rises above the v lko voltage threshold at which time flash memory write operations are allowed. once the upsd34xx is up and running, any subse- quent reset operation is referred to as a warm re- set, until power is turned off again. some psd module functions are reset in different ways de- pending if the reset condition was caused from a power-up reset or a warm reset. table 148., page 225 summarizes how psd module functions are affected by power-up and warm re- sets, as well as the affect of psd module power- down mode (from apd). the i/o pins of psd module ports a, b, c, and d do not have weak internal pull-ups.
225/264 upsd34xx - psd module in mcu i/o mode, latched address out mode, and peripheral i/o mode, the pins of ports a, b, c, and d become standard cmos inputs during a re- set condition. if no external devices are driving these pins during reset, then these inputs may float and draw excessive current. if low power con- sumption is critical during reset, then these floating inputs should be pulled up externally to v dd with a weak (100k ? minimum) resistor. in pld i/o mode, pins of ports a, b, c, and d may also float during reset if no external device is driv- ing them, and if there is no equation specified for the dpld or gpld to make them an output. in this case, a weak external pull-up resistor (100k ? min- imum) should be used on fl oating pins to avoid ex- cessive current draw. the pins on ports 1, 3, and 4 of the 8032 mcu module do have weak internal pull-ups and the in- puts will not float, so no external pull- ups are need- ed. table 148. function status during power- up reset, warm reset, power-down mode note: 1. vm register bit 7 (pio_en) and bit 0 (sram in 8032 program space) are cleared to zero at power-up and warm reset conditi ons. port configuration power-up reset warm reset apd power-down mode mcu i/o pins are in input mode pins are in input mode pin logic state is unchanged pld i/o pin logic is valid after internal psd module configuration bits are loaded. happens long before rst is de-asserted pin logic is valid and is determined by pld logic equations pin logic depends on inputs to pld (8032 addresses are blocked from reaching pld inputs during power- down mode) latched address out mode pins are high impedance pins are high impedance pins logic state not defined since 8032 address signals are blocked peripheral i/o mode pins are high impedance pins are high impedance pins are high impedance jtag isp and debug jtag channel is active and available jtag channel is active and available jtag channel is active and available register power-up reset warm reset apd power-down mode pmmr0 and pmmr2 cleared to 00h unchanged unchanged output of omc flip-flops cleared to ?0? depends on .re and .pr equations depends on .re and .pr equations vm register (1) initialized with value that was specified in psdsoft initialized with value that was specified in psdsoft unchanged all other csiop registers clear ed to 00h cleared to 00h unchanged
upsd34xx - psd module 226/264 jtag isp and jtag debug. an ieee 1149.1 serial jtag interface is used on upsd34xx devic- es for isp (in-system programming) of the psd module, and also for debugging firmware on the mcu module. ieee 1149.1 boundary scan oper- ations are not supported in the upsd34xx. the main advantage of jtag isp is that a blank upsd34xx device may be soldered to a circuit board and programmed with no involvement of the 8032, meaning that no 8032 firmware needs to be present for isp. this is good for manufacturing, for field updates, and for easy code development in the lab. jtag-based programmers and debug- gers for upsd34xx are available from stmicro- electronics and 3rd party vendors. isp is different than iap (in-application program- ming). iap involves the 8032 to program flash memory over any interface supported by the 8032 (e.g., uart, spi, i2c), wh ich is good for remote updates over a communication channel. upsd34xx devices support both isp and iap. the entire psd module (flash memory and pld) may be programmed with jtag isp, but only the flash memories may be programmed using iap. jtag chaining inside the package. jtag pro- tocol allows serial ?chainin g? of more than one de- vice in a jtag chain. the upsd34xx is assembled with a stacked die process combining the psd module (one die) and the mcu module (the other die). these two die are chained together within the upsd34xx package. the standard jtag interface has four basic signals: tdi - serial data into device tdo - serial data out of device tck - common clock tms - mode selection every device that supp orts ieee 1149.1 jtag communication contains a test access port (tap) controller, which is a sm all state machine to man- age jtag protocol and serial streams of com- mands and data. both the psd module and the mcu module each contain a tap controller. figure 91 illustrates how these die are chained within a package. jtag programming/test equip- ment will connect externa lly to the four ieee 1149.1 jtag pins on port c. the tdi pin on the upsd34xx package goes directly to the psd mod- ule first, then exits the psd module through tdo. tdo of the psd module is connected to tdi of the mcu module. the serial path is completed when tdo of the mcu module exits the upsd34xx package through the tdo pin on port c. the jtag signals tck and tms are common to both modules as specified in ieee 1149.1. when jtag devices are chained, typically one devices is in bypass mode while another device is executing a jtag operation. for the upsd34xx, the psd module is in bypass mo de while debugging the mcu module, and the mcu module is in bypass mode while performing isp on the psd module. the reset_in input pin on the upsd34xx pack- age goes to t he mcu module, and this module will generate the rst reset signal for the psd mod- ule. these reset signals are totally independent of the jtag tap controllers, meaning that the jtag channel is operational when the modules are held in reset. it is required to assert reset_in during isp. stmicroelectronics and 3rd party jtag isp tools will automatically asse rt a reset signal during isp. however, the user must connect this reset signal to reset_in as shown in examples in fig- ure figure 92., page 227 and figure 93., page 229 . figure 91. jtag chain in upsd34xx package jtag tdi jtag tms jtag tck jtag tdo tdi tms tck tdo tdo tms tck tdi pc3 / tstat pc4 / terr t s tat terr optional jtag tap controller jtag tap controller reset_in optional debug reset rst 8032 mcu mcu module psd module main flash memory 2nd flash memory pld upsd34xx ieee 1149.1 ai10460
227/264 upsd34xx - psd module in-system programming. the isp function can use two different configurations of the jtag inter- face: 4-pin jtag: tdi, tdo, tck, tms 6-pin jtag: signals above plus tstat, terr at power-up, the four basic jtag signals are all in- puts, waiting for a command to appear on the jtag bus from programming or test equipment. when the enabling command is received, tdo be- comes an output and the jtag channel is fully functional. the same command that enables the jtag channel may optionally enable the two addi- tional signals, tstat and terr . 4-pin jtag isp (default). the four basic jtag pins on port c are enabled for jtag operation at all times. these pins may not be used for other i/ o functions. there is no action needed in psdsoft express to configure a device to use 4-pin jtag, as this is the default c ondition. no 8032 firmware is needed to use 4-pin isp because all isp func- tions are controlled from the external jtag pro- gram/test equipment. figure 92 shows recommended connections on a circuit board to a jtag program/test tool using 4-pin jtag. it is re- quired to connect the rst output signal from the jtag program/test equip ment to the reset_in input on the upsd34xx. the rst signal is driven by the equipment with an open drain driver, allow- ing other sources (like a push button) to drive reset_in without conflict. note: the recommended pull-up resistors and de- coupling capacitor are illustrated in figure 92 . figure 92. recommended 4-pin jtag connections note: 1. for 5v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 5v system v dd . 2. for 3.3v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 3.3v system v cc . 3. this signal is driven by an open-drain output in the jtag equipment, allowing more than one source to activate reset in. tms - pc0 tck - pc1 sram stby or i/o - pc2 general i/o - pc3 general i/o - pc4 tdi - pc5 tdo - pc6 general i/o - pc7 jtag conn. 100k typical tms tck tdi tdo general i/o signals gnd v cc (1,2) rst (3) upsd34xx 0.01 f circuit board jtag programming or test equipment connects here 10k push button or any other reset source debug optional test point 100k resetin ai10457
upsd34xx - psd module 228/264 6-pin jtag isp (optional). the optional signals tstat and terr are programming status flags that can reduce programming time by as much as 30% compared to 4-pin jtag because this status information does not have to be scanned out of the device serially. tstat and terr must be used as a pair for 6-pin jtag operation. ? tstat (pin pc3) indicates when programming of a single flash location is complete. logic 1 = ready, logic 0 = busy. ?terr (pin pc4) indicates if there was a flash programming error. logic 1 = no error, logic 0 = error. the pin functions for pc3 and pc4 must be select- ed as ?dedicated jtag - tstat? and ?dedicated jtag - terr ? in psdsoft express to enable 6-pin jtag isp. no 8032 firmware is needed to use 6-pin isp be- cause all isp functions ar e controlled from the ex- ternal jtag program/test equipment. tstat and terr are functional only when jtag isp operations are occurring, which means they are non-functional during jtag debugging of the 8032 on the mcu module. programming times vary depending on the num- ber of locations to be programmed and the jtag programming equipment, but typical jtag isp programming times are 10 to 25 seconds using 6- pin jtag. the signals tstat and terr are not included in the ieee 1 149.1 specification. figure 93., page 229 shows recommended con- nections on a circuit board to a jtag program/test tool using 6-pin jtag. it is required to connect the rst output signal from the jtag program/test equipment to the reset_in input on the upsd34xx. the rst signal is driven by the equip- ment with an open drain driver, allowing other sources (like a push bu tton) to drive reset_in without conflict. note: the recommended pull-up resistors and de- coupling capacitor are illustrated in figure 93 .
229/264 upsd34xx - psd module figure 93. recommended 6-pin jtag connections note: 1. for 5v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 5v system v dd . 2. for 3.3v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 3.3v system v cc . 3. this signal is driven by an open-drain output in the jtag equipment, allowing more than one source to activate reset_in . tms - pc0 tck - pc1 sram stby or i/o - pc2 tstat - pc3 terr - pc4 tdi - pc5 tdo - pc6 general i/o - pc7 jtag conn. 100k typical tms tck tdi terr t s tat tdo general i/o signals gnd v cc (1,2) rst (3) upsd34xx 0.01 f circuit board jtag programming or test equipment connects here 10k push button or any other reset source debug optional test point 100k resetin ai10458
upsd34xx - psd module 230/264 recommended jtag connector. there is no industry standard jtag connector. stmicroelec- tronics recommends a specific jtag connector and pinout for upsd3xxx so programming and de- bug equipment will easily connect to the circuit board. the user does not ha ve to use this connec- tor if there is a different connection scheme. the recommended connector scheme can accept a standard 14-pin ribbon cable connector (2 rows of 7 pins on 0.1? centers, 0.025? square posts, standard keying) as shown in figure 94 . see the stmicroelectronics ?flashlink, fl-101 user manual? for more information. figure 94. recommended jtag connector chaining upsd34xx devices. it is possible to chain a upsd34xx device with other upsd34xx devices on a circuit board, and also chain with ieee 1149.1 compliant devices from other manu- facturers. figure 95., page 231 shows a chaining example. the tdo of one device connects to the tdi of the next device, and so on. only one device is performing jtag operations at any given time while the other two devices are in bypass mode. configuration for jtag chaining can be made in psdsoft express by choosing ?more than one de- vice? when prompted about chaining devices. no- tice in figure 95., page 231 that the upsd34xx devices are chained externally, but also be aware that the two die within each upsd34xx device are chained internally. this internal chaining of die is transparent to the user and is taken care of by ps- dsoft express and 3rd party jtag tool software. the example in figure 95., page 231 also shows how to use 6-pin jtag when chaining devices. the signals tstat and terr are configured as open-drain type signals from psdsoft express. this facilitates a wired-o r connection of tstat signals from multiple upsd34xx devices and also a wired-or connection of terr signals from those same multiple dev ices. psdsoft express puts tstat and terr signals into open-drain mode by default, requiring external pull-up resis- tors. click on 'properties' in the jtag-isp window of psdsoft express to change to standard cmos push-pull outputs if desired, but wired-or logic is not possible in cmos output mode. tdo tck tms v cc tdi gnd jen terr gnd gnd rst tstat cntl trst 14 12 10 13 11 9 7 8 6 5 4 3 2 1 key way view: looking into face of shrouded male connector, with 0.025" posts on 0.1" centers. connector reference: molex 70247-1401 this connector accepts a 14-pin ribbon cable such as:  samtec: hcsd-07-d-06.00-01-s-n  digikey: m3cck-14065-nd ai09187
231/264 upsd34xx - psd module figure 95. example of ch aining upsd34xx devices device 1 psd34xx upsd34xx tms tck tdi tdo ieee 1149.1 compliant device device 2 device n system reset circuitry tms tck tdi tdo t s tat terr circuit board jtag conn. v cc tms tck tdi t s tat terr tdo rst gnd 100k 100k 100k 100k 100k 10k 100k jtag programming or test equipment connects here optional optional tms tck tdi tdo t s tat terr ai10459
upsd34xx - psd module 232/264 debugging the 8032 mcu module. the 8032 on the mcu module may be debugged in-circuit using the same four basic jtag signals as used for jtag isp (tdi, tdo, tck, tms). the signals tstat and terr are not needed for debugging, and they will not create a problem if they exist on the circuit board while debugging. the same con- nector specified in figure 94., page 230 can be used for isp or for 8032 debugging. there are 3rd party suppliers of upsd34xx jtag debugging equipment (check www.st.c om/psm). these are small pods which connect to a pc (or notebook computer) using a usb interface, and they are driven by an 8032 integrated development envi- ronment (ide) running on the pc. standard debugging features are provided through this jtag interf ace such as single-step, breakpoints, trace, memory dump and fill, and oth- ers. there is also a dedicated debug pin (shown in figure 91., page 226 ) which can be configured as an output to trigger external devices upon a programmable internal event (e.g., breakpoint match), or the pin can be configured as an input so an external device can initiate an internal debug event (e.g., break execution). the debug pin func- tion is configured by the 8032 ide debug software tool. see debug unit, page 40 for more details. the debug signal should always be pulled up ex- ternally with a weak pull-up (100k minimum) to v cc even if nothing is connected to it, as shown in figure 92., page 227 and figure 93., page 229 . jtag security setting. a programmable securi- ty bit in the psd module protects its contents from unauthorized viewing and copying. the security bit is set by clicking on the ?additional psd set- tings? box in the main flow diagram of psdsoft ex- press, then choosing to set the security bit. once a file with this setting is programmed into a upsd34xx using jtag isp, any further attempts to communicate with the upsd34xx using jtag will be limited. once secur ed, the only jtag oper- ation allowed is a full-chip erase. no reading or modifying flash memory or pld logic is allowed. debugging operations to the mcu module are also not allowed. the only way to defeat the secu- rity bit is to perform a jtag isp full-chip erase op- eration, after which the device is blank and may be used again. th e 8032 on the mcu module will al- ways have access to psm module memory con- tents through the 8-bit 8032 data bus connecting the two die, even while the security bit is set. initial delivery state. when delivered from st- microelectronics, upsd34xx devices are erased, meaning all flash memory and pld configuration bits are logic '1.' firmware and pld logic configu- ration must be programmed at least the first time using jtag isp. subsequent programming of flash memory may be performed using jtag isp, jtag debugging, or the 8032 may run firmware to program flash memory (iap).
233/264 upsd34xx - ac/dc parameters ac/dc parameters these tables describe the ad and dc parameters of the upsd34xx devices: dc electrical specification ac timing specification pld timing ? combinatorial timing ? synchronous clock mode ? asynchronous clock mode ? input macrocell timing mcu module timing ?read timing ? write timing ? power-down and reset timing the following are issues concerning the parame- ters presented: ? in the dc specification the supply current is given for different modes of operation. ? the ac power component gives the pld, flash memory, and sram ma/mhz specification. figure 96 and figure 97 show the pld ma/mhz as a function of the number of product terms (pt) used. ? in the pld timing parameters, add the required delay when turbo bit is '0.' figure 96. pld i cc /frequency consumption (5v range) figure 97. pld i cc /frequency consumption (3v range) 0 10 20 30 40 60 70 80 90 100 110 v cc = 5v 50 01015 5 20 25 highest composite frequency at pld inputs (mhz) i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off pt 100% pt 25% ai02894 0 10 20 30 40 50 60 v cc = 3v 01015 5 20 25 i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off highest composite frequency at pld inputs (mhz) pt 100% pt 25% ai03100
upsd34xx - ac/dc parameters 234/264 table 149. psd module example, typ. power calculation at v cc = 5.0v (turbo mode off) conditions mcu clock frequency = 12mhz highest composite pld input frequency (freq pld) = 8mhz mcu ale frequency (freq ale) = 2mhz % flash memory access = 80% % sram access = 15% % i/o access = 5% (no additional power above base) operational modes % normal = 40% % power-down mode = 60% number of product terms used (from fitter report) = 45 pt % of total product terms = 45/182 = 24.7% turbo mode = off calculation (using typical values) i cc total = i cc (mcuactive) x %mcuactive + i cc (psdactive) x %psdactive + i pd (pwrdown) x %pwrdown i cc (mcuactive) = 20ma i pd (pwrdown) = 250ua i cc (psdactive) = i cc (ac) + i cc (dc) = %flash x 2.5ma/mhz x freq ale + %sram x 1.5ma/mhz x freq ale + % pld x (from graph using freq pld) = 0.8 x 2.5ma/mhz x 2mhz + 0.15 x 1.5ma/mhz x 2mhz + 24ma = (4 + 0.45 + 24) ma = 28.45ma i cc total = 20ma x 40% + 28.45ma x 40% + 250ua x 60% = 8ma + 11.38ma + 150ua = 19.53ma this is the operating power with no flash memory erase or program cycles in progress. calculation is based on all i/o pins being disconnected and i out = 0ma.
235/264 upsd34xx - maximum rating maximum rating stressing the device above the rating listed in the absolute maximum ratings? table may cause per- manent damage to the device. these are stress ratings only and operation of the device at these or any other conditions above those indicated in the operating sections of this specification is not im- plied. exposure to abso lute maximum rating con- ditions for extended periods may affect device reliability. refer also to the stmicroelectronics sure program and other relevant quality docu- ments. table 150. absolute maximum ratings note: 1. ipc/jedec j-std-020a 2. jedec std jesd22-a114a (c1=100pf, r1=1500 ? , r2=500 ? ) dc and ac parameters this section summarizes the operating and mea- surement conditions, and the dc and ac charac- teristics of the device. the parameters in the dc and ac characteristic tables that follow are de- rived from tests performed under the measure- ment conditions summarized in the relevant tables. designers should check that the operating conditions in their circuit match the measurement conditions when relying on the quoted parame- ters. table 151. operating conditions (5v devices) table 152. operating conditions (3.3v devices) symbol parameter min. max. unit t stg storage temperature ?65 125 c t lead lead temperature during sol dering (20 seconds max.) (1) 235 c v io input and output voltage (q = v oh or hi-z) ?0.5 6.5 v v cc supply voltage ?0.5 6.5 v v pp device programmer supply voltage ?0.5 14.0 v v esd electrostatic discharge vo ltage (human body model) (2) ?2000 2000 v symbol parameter min. max. unit v cc supply voltage 4.5 5.5 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 0 70 c symbol parameter min. max. unit v cc supply voltage 3.0 3.6 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 0 70 c
upsd34xx - dc and ac parameters 236/264 table 153. ac signal letters for timing note: example: t avlx = time from address valid to ale invalid. table 154. ac signal behavior symbols for timing note: example: t avlx = time from address valid to ale invalid. figure 98. switching waveforms ? key a address cclock d input data i instruction lale n reset input or output p psen signal q output data r rd signal w wr signal b v stby output m output macrocell ttime l logic level low or ale h logic level high vvalid x no longer a valid logic level z float pw pulse width waveforms inputs outputs steady input may change from hi to lo may change from lo to hi don't care outputs only steady output will be changing from hi to lo will be changing lo to hi changing, state unknown center line is tri-state ai03102
237/264 upsd34xx - dc and ac parameters table 155. major parameters note: 1. operating current is measured while the upsd34xx is executing a typical program at 40mhz. parameter test conditions/comme nts 5.0v value 3.3v value unit operating voltage ? 4.5 to 5.5 (psd); 3.0 to 3.6 (mcu) 3.0 to 3.6 (psd and mcu) v operating temperature ? ?40 to 85 ?40 to 85 c mcu frequency 8mhz (min) for i 2 c 3 min, 40 max 3 min, 40 max mhz operating current, typical (1) (20% of pld used; 25c operation. bus control signals are blocked from the pld in non- turbo mode.) 40mhz crystal, turbo 79 63 ma 40mhz crystal, non-turbo 71 58 ma 8mhz crystal, turbo 32 24 ma 8mhz crystal, non-turbo 17.7 14 ma idle current, typical (20% of pld used; 25c operation) 40mhz crystal divided by 2048 internally. all interfaces are disabled. 19 18 ma standby current, typical power-down mode needs reset to exit. 140 120 a sram backup current, typical if external battery is attached. 0.5 0.5 a i/o sink/source current, ports a, b, c, and d v ol = 0.45v (max); v oh = 2.4v (min) i ol = 8 (max); i oh = ?2 (min) i ol = 4 (max); i oh = ?1 (min) ma i/o sink/source current, port 4 v ol = 0.6v (max); v oh = 2.4v (min) i ol = 10 (max); i oh = ?10 (min) i ol = 10 (max); i oh = ?10 (min) ma pld macrocells for registered or combinatorial logic 16 16 ? pld inputs inputs from pins, feedback, or mcu addresses 69 69 ? pld outputs output to pins or internal feedback 18 18 ? pld propagation delay, typical, turbo mode pld input to output 15 22 ns
upsd34xx - dc and ac parameters 238/264 table 156. preliminary mcu module dc characteristics note: 1. power supply (v cc ) is always 3.0 to 3.6v for the mcu module. v dd for the psd module may be 3v or 5v. 2. port 1 is not 5v tolerant; maximum v ih = v cc + 0.5. 3. i pd (power-down mode) is measured with: xtal1 = v ss ; xtal2 = nc; reset = v cc ; port 0 = v cc ; all other pins are disconnected. 4. i cc-cpu (active mode) is measured with: xtal1 driven with t clch , t chcl = 5ns, v il = v ss + 0.5v, v ih = v cc ? 0.5v, xtal2 = nc; reset = v ss ; port 0 = v cc ; all other pins are disconnected. i cc would be slightly higher if a crystal oscillator is used (approximately 1ma). 5. i cc-cpu (idle mode) is measured with: xtal1 driven with t clch , t chcl = 5ns, v il = v ss + 0.5v, v ih = v cc ? 0.5v, xtal2 = nc; reset = v cc ; port 0 = v cc ; all other pins are disconnected. i cc would be slightly higher if a crystal oscillator is used (approximately 1ma). all ip clocks are disabled and the mcu clock is set to f osc /2048. 6. i/o current = 0ma, all i/o pins are disconnected. symbol parameter test conditions min. typ. max. unit v cc supply voltage (1) 3.0 3.6 v v ih high level input voltage (ports 0, 1, 3, 4, xtal1, reset) 5v tolerant - max voltage 5.5v 3.0v < v cc < 3.6v 0.7v cc 5.5 (2) v v il low level input voltage (ports 0, 1, 3, 4, xtal1, reset) 3.0v < v cc < 3.6v v ss ? 0.5 0.3v cc v v ol1 output low voltage (port 4) i ol = 10ma 0.6 v v v ol2 output low voltage (other ports) i ol =5ma 0.6 v v v oh1 output high voltage (ports 4 push-pull) i oh = ?10ma 2.4 v v v oh2 output high voltage (port 0 push-pull) i oh = ?5ma 2.4 v v v oh3 output high voltage (other ports bi -directional mode) i oh = ?20a 2.4 v v v op xtal open bias voltage (xtal1, xtal2) i ol = 3.2ma 1.0 2.0 v i rst reset pin pull-up current (reset) v in = v ss ?10 ?55 ua i fr xtal feedback resistor current (xtal1) xtal1 = v cc ; xtal2 = v ss ?20 50 ua i ihl1 input high leakage current (port 0) v ss < v in < 5.5v ?10 10 ua i ihl2 input high leakage current (port 1, 3, 4) v ih = 2.3v ?10 10 ua i ill input low leakage current (port 1, 3, 4) v il < 0.5v ?10 10 ua i pd (3) power-down mode v cc = 3.6v 65 95 ua i cc-cpu (notes 4,5,6) active - 12mhz v cc = 3.6v 14 20 ma idle - 12mhz 10 12 ma active - 24mhz v cc = 3.6v 19 30 ma idle - 24mhz 13 17 ma active - 40mhz v cc = 3.6v 26 40 ma idle - 40mhz 17 22 ma
239/264 upsd34xx - dc and ac parameters table 157. psd module dc characteristics (with 5v v dd ) note: 1. internal power-down mode is active. 2. pld is in non-turbo mode, and none of the inputs are switching. 3. please see figure 96., page 233 for the pld current calculation. 4. i out = 0ma symbol parameter test condition (in addition to those in table 156., page 238 ) min. typ. max. unit v ih input high voltage 4.5v < v dd < 5.5v 2 v dd +0.5 v v il input low voltage 4.5v < v dd < 5.5v ?0.5 0.8 v v lko v dd (min) for flash erase and program 2.5 4.2 v v ol output low voltage i ol = 20ua, v dd = 4.5v 0.01 0.1 v i ol = 8ma, v dd = 4.5v 0.25 0.45 v v oh output high voltage except v stby on i oh = ?20ua, v dd = 4.5v 4.4 4.49 v i oh = ?2ma, v dd = 4.5v 2.4 3.9 v v oh1 output high voltage v stby on i oh1 = 1ua v stby ? 0.8 v v stby sram stand-by voltage 2.0 v dd v i stby sram stand-by current v dd = 0v 0.5 1 ua i idle idle current (v stby input) v dd > v stby ?0.1 0.1 ua v df sram data retention voltage only on v stby 2 v dd ? 0.2 v i sb stand-by supply current for power-down mode csi > v dd ? 0.3v (notes 1,2) 120 250 ua i li input leakage current v ss < v in < v dd ?1 0.1 1 ua i lo output leakage current 0.45 < v out < v dd ?10 5 10 ua i cc (dc) (note 4) operating supply current pld only pld_turbo = off, f = 0mhz (note 4) 0 ua/pt pld_turbo = on, f = 0mhz 400 700 ua/pt flash memory during flash memory write/erase only 15 30 ma read only, f = 0mhz 0 0 ma sram f = 0mhz 0 0 ma i cc (ac) (note 4) pld ac adder note 3 flash memory ac adder 1.5 2.5 ma/ mhz sram ac adder 1.5 3.0 ma/ mhz
upsd34xx - dc and ac parameters 240/264 table 158. psd module dc characteristics (with 3.3v v dd ) note: 1. internal pd is active. 2. pld is in non-turbo mode, and none of the inputs are switching. 3. please see figure 97., page 233 for the pld current calculation. 4. i out = 0ma symbol parameter test condition (in addition to those in table 156., page 238 ) min. typ. max. unit v ih high level input voltage 3.0v < v dd < 3.6v 0.7v dd v dd +0.5 v v il low level input voltage 3.0v < v dd < 3.6v ?0.5 0.8 v v lko v dd (min) for flash erase and program 1.5 2.2 v v ol output low voltage i ol = 20ua, v dd = 3.0v 0.01 0.1 v i ol = 4ma, v dd = 3.0v 0.15 0.45 v v oh output high voltage except v stby on i oh = ?20ua, v dd = 3.0v 2.9 2.99 v i oh = ?1ma, v dd = 3.0v 2.7 2.8 v v oh1 output high voltage v stby on i oh1 = 1ua v stby ? 0.8 v v stby sram stand-by voltage 2.0 v dd v i stby sram stand-by current v dd = 0v 0.5 1 ua i idle idle current (v stby input) v dd > v stby ?0.1 0.1 ua v df sram data retention voltage only on v stby 2 v dd ? 0.2 v i sb stand-by supply current for power-down mode csi > v dd ? 0.3v (notes 1,2) 50 100 ua i li input leakage current v ss < v in < v dd ?1 0.1 1 ua i lo output leakage current 0.45 < v in < v dd ?10 5 10 ua i cc (dc) (note 4) operating supply current pld only pld_turbo = off, f = 0mhz (note 2) 0 ua/pt pld_turbo = on, f = 0mhz 200 400 ua/pt flash memory during flash memory write/erase only 10 25 ma read only, f = 0mhz 0 0 ma sram f = 0mhz 0 0 ma i cc (ac) (note 4) pld ac adder note 3 flash memory ac adder 1.0 1.5 ma/ mhz sram ac adder 0.8 1.5 ma/ mhz
241/264 upsd34xx - dc and ac parameters figure 99. external read cycle (80-pin device only) table 159. external read cycle ac characteristics (3v or 5v device) note: 1. buscon register is configured for 4 pfqclk. 2. refer to table 160 for ?n? and ?m? values. table 160. n, m, and x, y values symbol parameter 40mhz oscillator (1) variable oscillator 1/t clcl = 3 to 40mhz unit min max min max t lhll ale pulse width 17 t clcl ? 8 ns t avll address setup to ale 13 t clcl ? 12 ns t llax address hold after ale 7.5 0.5t clcl ? 5 ns t llrl ale to r d 7.5 0.5t clcl ? 5 ns t rlrh r d pulse width (2) 40 nt clcl ? 10 ns t rxix input data hold after r d 22ns t rhiz input data float after r d 10.5 0.5t clcl ? 2 ns t avdx address to valid data in (2) 70 mt clcl ? 5 ns t azrl address float to r d ?2 ?2 ns t avqv address valid to latched address out on ports a and b 35.5 (3v) 1.5t clcl ? 2 ns 28 (5v) t clcl ? 9.5 ns # of pfqclk in buscon reg. read cycle write cycle nmx y 4 2321 5 3432 6 4543 7 5654 t avll t rlrh t rxdz mcu ad0 - ad7 latched mcu a8 - a15 ai10471 t lhll ale rd t llrl a0-a7 t llax t azrl t avdv a0-a7 t rxdx t avqv a8-a15 data in a8-a15
upsd34xx - dc and ac parameters 242/264 figure 100. external write cycle (80-pin device only) table 161. external write cycle ac characteristics (3v or 5v device) note: 1. buscon register is configured for 4 pfqclk. 2. refer to table 162., page 243 , for ?n? and ?m? values. 3. latched address out on ports a and b to wr is 2ns, minimum. symbol parameter 40mhz oscillator (1) variable oscillator 1/t clcl = 8 to 40mhz unit min max min max t lhll ale pulse width 17 t clcl ? 8 ns t avll address setup to ale 13 t clcl ? 12 ns t llax address hold after ale 7.5 0.5t clcl ? 5 ns t wlwh wr pulse width (2) 40 xt clcl ? 10 ns t llwl ale to wr 7.5 0.5t clcl ? 5 ns t avwl address (a0-a7) valid to wr (3) 32.5 1.5t clcl ? 5 ns t whlh wr high to ale high 9.5 9.5 0.5t clcl ? 3 0.5t clcl + 2 ns t qvwh data setup before wr (y) 20 yt clcl ? 5 ns t whqx data hold after wr 9.5 14.5 0.5t clcl ? 3 0.5t clcl + 2 ns t avqv address valid to latched address out on ports a and b 35.5 (3v) 1.5t clcl ? 2 ns 28 (5v) t clcl ? 9.5 ns latched mcu a8 - a15 mcu ad0 - ad7 ale wr rd a8-a15 a8-a15 tllwl twlwh tavll tlhll tqvwh data out a0-a7 data in a0-a7 tllax tavwl tavqv twhqx twhlh ai10472
243/264 upsd34xx - dc and ac parameters table 162. external clock drive table 163. a/d analog specification note: 1. f in 2khz, aclk = 8mhz, av ref = v cc = 3.3v 2. av ref = v cc in 52-pin package. symbol parameter (1) 40mhz oscillator variable oscillator 1/t clcl = 3 to 40mhz unit min max min max t clcl oscillator period 25 333 ns t chcx high time 10 t clcl ? t clcx ns t clcx low time 10 t clcl ? t clcx ns t clch rise time 10 ns t chcl fall time 10 ns symbol parameter test conditions (1) min. typ. max. unit i dd normal input = av ref 4.0 ma power-down 40 ua av in analog input voltage gnd av ref v av ref (2) analog reference voltage 3.6 v accuracy resolution 10 bits inl integral nonlinearity input = 0 to av ref (v) f osc 32mhz 2 lsb dnl differential nonlinearity input = 0 to av ref (v) f osc 32mhz 2 lsb snr signal to noise ratio f sample = 500ksps 50 54 db sndr signal to noise distortion ratio 48 52 db aclk adc clock 2 8 16 mhz t c conversion time 8mhz 1 4 8 s t cal power-up time calibration time 16 ms f in analog input frequency 60 khz thd total harmonic distortion 50 54 db
upsd34xx - dc and ac parameters 244/264 table 164. usb transceiver specification note: 1. temperature range = ?45c to 85c. 2. this value includes an external resistor of 24 ? 1%. symbol parameter test conditions (1) min. typ. max. unit uv oh high output voltage v dd = 3.3v; i out = 2.2ma 3?v uv ol low output voltage v dd = 3.3v; i out = 2.2ma ?0.25v uv ih high input voltage v dd = 3.6v 2?v uv il low input voltage v dd = 3.6v 0.8 v r dh output impedance (high state) note 2 28 43 ? r dl output impedance (low state) note 2 28 43 ? i l input leakage current v dd = 3.6v 0.1 5 a i oz 3-state output off state current vi = v ih or v il 10 a v cr crossover point 1.3 2 v t rise rise time 4 20 ns t fall fall time 4 20 ns
245/264 upsd34xx - dc and ac parameters figure 101. input to output disable / enable table 165. cpld combinat orial timing (5v psd module) note: 1. fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount 2. t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) table 166. cpld combinat orial timing (3v psd module) note: 1. fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount 2. t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) symbol parameter conditions min max pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 20 + 2 + 10 ? 2 ns t ea cpld input to cpld output enable 21 + 10 ? 2 ns t er cpld input to cpld output disable 21 + 10 ? 2 ns t arp cpld register cl ear or preset delay 21 + 10 ? 2 ns t arpw cpld register cl ear or preset pulse width 10 + 10 ns t ard cpld array delay any macrocell 11 + 2 ns symbol parameter conditions min max pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 35 + 4 + 15 ? 6 ns t ea cpld input to cpld output enable 38 + 15 ? 6 ns t er cpld input to cpld output disable 38 + 15 ? 6 ns t arp cpld register clear or preset delay 35 + 15 ? 6 ns t arpw cpld register clear or preset pulse width 18 + 15 ns t ard cpld array delay any macrocell 20 + 4 ns ter tea input input to output enable/disable ai02863
upsd34xx - dc and ac parameters 246/264 figure 102. synchronous cl ock mode timing ? pld table 167. cpld macrocell synchronous clock mode timing (5v psd module) note: 1. fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount. 2. clkin (pd1) t clcl = t ch + t cl .105 symbol parameter conditions min max pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co ) 40.0 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ?10) 66.6 mhz maximum frequency pipelined data 1/(t ch +t cl ) 83.3 mhz t s input setup time 12 + 2 + 10 ns t h input hold time 0 ns t ch clock high time clock input 6 ns t cl clock low time clock input 6 ns t co clock to output delay clock input 13 ? 2 ns t ard cpld array delay any macrocell 11 + 2 ns t min minimum clock period (2) t ch +t cl 12 ns t ch t cl t co t h t s clkin input registered output ai02860
247/264 upsd34xx - dc and ac parameters table 168. cpld macrocell synchronous clock mode timing (3v psd module) note: 1. fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount. 2. clkin (pd1) t clcl = t ch + t cl . symbol parameter conditions min max pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co ) 23.2 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ?10) 30.3 mhz maximum frequency pipelined data 1/(t ch +t cl ) 40.0 mhz t s input setup time 20 + 4 + 15 ns t h input hold time 0 ns t ch clock high time clock input 15 ns t cl clock low time clock input 10 ns t co clock to output delay clock input 23 ? 6 ns t ard cpld array delay any macrocell 20 + 4 ns t min minimum clock period (2) t ch +t cl 25 ns
upsd34xx - dc and ac parameters 248/264 figure 103. asynchronous reset / preset figure 104. asynchronous clock mode timing (product term clock) table 169. cpld macrocell asynchronous clock mode timing (5v psd module) symbol parameter conditions min max pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa ) 38.4 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ?10) 62.5 mhz maximum frequency pipelined data 1/(t cha +t cla ) 71.4 mhz t sa input setup time 7 + 2 + 10 ns t ha input hold time 8 ns t cha clock input high time 9 + 10 ns t cla clock input low time 9 + 10 ns t coa clock to output delay 21 + 10 ? 2 ns t arda cpld array delay any macrocell 11 + 2 ns t mina minimum clock period 1/f cnta 16 ns tarp register output tarpw reset/preset input ai02864 tcha tcla tcoa tha tsa clock input registered output ai02859
249/264 upsd34xx - dc and ac parameters table 170. cpld macrocell asynchronous clock mode timing (3v psd module) symbol parameter conditions min max pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa ) 21.7 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ?10) 27.8 mhz maximum frequency pipelined data 1/(t cha +t cla ) 33.3 mhz t sa input setup time 10 + 4 + 15 ns t ha input hold time 12 ns t cha clock high time 17 + 15 ns t cla clock low time 13 + 15 ns t coa clock to output delay 31 + 15 ? 6 ns t ard cpld array delay any macrocell 20 + 4 ns t mina minimum clock period 1/f cnta 36 ns
upsd34xx - dc and ac parameters 250/264 figure 105. input macrocell timing (product term clock) table 171. input macroc ell timing (5v psd module) note: 1. inputs from port a, b, and c relative to register/ latch clock from the pld. ale/as latch timings refer to t avlx and t lxax . table 172. input macroc ell timing (3v psd module) note: 1. inputs from port a, b, and c relative to register/latch clock from the pld. ale latch timings refer to t avlx and t lxax . symbol parameter conditions min max pt aloc turbo off unit t is input setup time (note 1) 0ns t ih input hold time (note 1) 15 + 10 ns t inh nib input high time (note 1) 9ns t inl nib input low time (note 1) 9ns t ino nib input to combinatorial delay (note 1) 34 + 2 + 10 ns symbol parameter conditions min max pt aloc turbo off unit t is input setup time (note 1) 0ns t ih input hold time (note 1) 25 + 15 ns t inh nib input high time (note 1) 12 ns t inl nib input low time (note 1) 12 ns t ino nib input to combinatorial delay (note 1) 43 + 4 + 15 ns t inh t inl t ino t ih t is pt clock input output ai03101
251/264 upsd34xx - dc and ac parameters table 173. program, write and erase times (5v, 3v psd modules) note: 1. programmed to all zero before erase. 2. typical after 100k write/erase cycles is 5 seconds. 3. the polling status, dq7, is valid t q7vqv time units before the data byte, dq0-dq7, is valid for reading. symbol parameter min. typ. max. unit flash program 8.5 s flash bulk erase (1) (pre-programmed) 3 (2) 10 s flash bulk erase (not pre-programmed) 5 s t whqv3 sector erase (pre-programmed) 1 10 s t whqv2 sector erase (not pre-programmed) 2.2 s t whqv1 byte program 14 150 s program / erase cycles (per sector) 100,000 cycles pld program / erase cycles 1,000 cycles t whwlo sector erase time-out 100 s t q7vqv dq7 valid to output (dq7-dq0) valid (data polling) (3) 30 ns
upsd34xx - dc and ac parameters 252/264 figure 106. peripheral i/o read timing table 174. port a peripheral data mode read timing (5v psd module) note: 1. any input used to select port a data peripheral mode. 2. data is already stable on port a. table 175. port a peripheral data mode read timing (3v psd module) note: 1. any input used to select port a data peripheral mode. 2. data is already stable on port a. symbol parameter conditions min max turbo off unit t avqv?pa address valid to data valid (note 1) 37 + 10 ns t slqv?pa csi valid to data valid 27 + 10 ns t rlqv?pa rd to data valid (note 2) 32 ns t dvqv?pa data in to data out valid 22 ns t rhqz?pa rd to data high-z 23 ns symbol parameter conditions min max turbo off unit t avqv?pa address valid to data valid (note 1) 50 + 15 ns t slqv?pa csi valid to data valid 37 + 15 ns t rlqv?pa rd to data valid (note 2) 45 ns t dvqv?pa data in to data out valid 38 ns t rhqz?pa rd to data high-z 36 ns t rlqv ( pa) t dvqv ( pa) t rhqz ( pa) t slqv ( pa) t avqv ( pa) address data valid ale a /d bus rd data on port a csi ai06610
253/264 upsd34xx - dc and ac parameters figure 107. peripheral i/o write timing table 176. port a peripheral data mode write timing (5v psd module) note: 1. data stable on port 0 pins to data on port a. table 177. port a peripheral data mode write timing (3v psd module) note: 1. data stable on port 0 pins to data on port a. table 178. supervisor reset and lvd note: 1. 25s minimum to abort a flash memory program or erase cycle in progress. 2. as f osc decreases, t rst_actv increases. example: t rst_actv = 50ms when f osc = 8mhz. symbol parameter conditions min max unit t wlqv?pa wr to data propagation delay 25 ns t dvqv?pa data to port a data propagation delay (note 1) 22 ns t whqz?pa wr invalid to port a tri-state 20 ns symbol parameter conditions min max unit t wlqv?pa wr to data propagation delay 42 ns t dvqv?pa data to port a data propagation delay (note 1) 38 ns t whqz?pa wr invalid to port a tri-state 33 ns symbol parameter conditions min typ max unit t rst_lo_in reset input duration 1 (1) s t rst_actv generated reset duration f osc = 40mhz 10 (2) ms t rst_fil reset input spike filter 1 s v rst_hys reset input hysteresis v cc = 3.3v 0.1 v v rst_thresh lvd trip threshold v cc = 3.3v 2.4 2.6 2.8 v tdvqv (pa) twlqv (pa) twhqz (pa) address data out a /d bus wr port a data out ale ai06611
upsd34xx - dc and ac parameters 254/264 table 179. v stbyon definitions timing (5v, 3v psd modules) note: 1. v stbyon timing is measured at v cc ramp rate of 2ms. figure 108. isc timing table 180. isc timing (5v psd module) note: 1. for non-pld programming, erase or in isc by-pass mode. 2. for program or erase pld only. symbol parameter conditions min typ max unit t bvbh v stby detection to v stbyon output high (note 1) 20 s t bxbl v stby off detection to v stbyon output low (note 1) 20 s symbol parameter conditions min max unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 20 mhz t iscch clock (tck, pc1) high time (except for pld) (note 1) 23 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 23 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 4mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 90 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 90 ns t iscpsu isc port set up time 7 ns t iscph isc port hold up time 5 ns t iscpco isc port clock to output 21 ns t iscpzv isc port high-impedance to valid output 21 ns t iscpvz isc port valid output to high-impedance 21 ns iscch tck tdi/tms isc outputs/tdo isc outputs/tdo t isccl t iscph t iscpsu t iscpvz t iscpzv t iscpco t ai02865
255/264 upsd34xx - dc and ac parameters table 181. isc timing (3v psd module) note: 1. for non-pld programming, erase or in isc by-pass mode. 2. for program or erase pld only. figure 109. mcu module ac measurement i/o waveform note: ac inputs during testing are driven at v cc ?0.5v for a logic '1,' and 0.45v for a logic '0.' timing measurements are made at v ih (min) for a logic '1,' and v il (max) for a logic '0' figure 110. psd module ac float i/o waveform note: for timing purposes, a port pin is considered to be no longer floating when a 100mv change from load voltage occurs, and b egins to float when a 100mv change from the loaded v oh or v ol level occurs i ol and i oh 20ma symbol parameter conditions min max unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 16 mhz t iscch clock (tck, pc1) high time (except for pld) (note 1) 40 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 40 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 4mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 90 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 90 ns t iscpsu isc port set up time 12 ns t iscph isc port hold up time 5 ns t iscpco isc port clock to output 30 ns t iscpzv isc port high-impedance to valid output 30 ns t iscpvz isc port valid output to high-impedance 30 ns ai06650 v cc ? 0.5v 0.45v test points 0.2 v cc ? 0.1v 0.2 v cc + 0.9v ai06651 test reference points v ol + 0.1v v oh ? 0.1v v load ? 0.1v v load + 0.1v 0.2 v cc ? 0.1v
upsd34xx - dc and ac parameters 256/264 figure 111. external clock cycle figure 112. psd module ac measurement i/o waveform figure 113. psd module ac measurement load circuit table 182. i/o pin capacitance note: 1. sampled only, not 100% tested. 2. typical values are for t a = 25c and nominal supply voltages. 3. maximum for mcu address and data lines is 20pf each. 3.0v 0v test point 1.5v ai03103b device under test 2.01 v 195 ? c l = 30 pf (including scope and jig capacitance) ai03104b symbol parameter (1) test condition typ. (2) max. unit c in input capacitance (for input pins) v in = 0v 46 pf c out output capacitance (for input/ output pins) (3) v out = 0v 812 pf
257/264 upsd34xx - package mechanical information package mechanical information figure 114. tqfp52 ? 52-lead plastic thin, quad, flat package outline note: drawing is not to scale. qfp-a nd e1 cp b e a2 a n l a1 d1 d 1 e ne c d2 e2 l1
upsd34xx - package mechanical information 258/264 table 183. tqfp52 ? 52-lead plastic thin, quad, flat package mechanical data symb mm inches typ min max typ min max a 1.50 ? 1.70 0.059 ? 0.067 a1 0.10 0.05 0.20 0.004 0.002 0.008 a2 1.40 1.30 1.50 0.055 0.039 0.059 b ? 0.20 0.40 ? 0.008 0.016 c ? 0.07 0.20 ? 0.003 0.008 d 12.00 11.80 12.20 0.472 0.465 0.480 d1 10.00 9.80 10.20 0.394 0.386 0.402 d2 7.80 7.67 7.93 0.307 0.302 0.312 e 12.00 11.80 12.20 0.472 0.465 0.480 e1 10.00 9.80 10.20 0.394 0.386 0.402 e2 7.80 7.67 7.93 0.307 0.302 0.312 e0.65? ?0.026? ? l ? 0.45 0.75 ? 0.018 0.030 l1 1.00 ? ? 0.039 ? ? ? 0 7 ? 0 7 n52 52 nd 13 13 ne 13 13 cp ? ? 0.10 ? ? 0.004
259/264 upsd34xx - package mechanical information figure 115. tqfp80 ? 80-lead plastic thin, quad, flat package outline note: drawing is not to scale. qfp-a nd e1 cp b e a2 a n l a1 d1 d 1 e ne c d2 e2 l1
upsd34xx - package mechanical information 260/264 table 184. tqfp80 ? 80-lead plastic thin, quad, flat package mechanical data symb mm inches typ min max typ min max a 1.60 0.063 a1 0.05 0.15 0.002 0.006 a2 1.40 1.35 1.45 0.055 0.053 0.057 b 0.17 0.27 0.007 0.011 c 0.09 0.20 0.004 0.008 d 14.00 0.551 d1 12.00 0.472 d2 9.50 0.374 e 14.00 0.551 e1 12.00 0.472 e2 9.50 0.374 e 0.50 0.020 l 0.45 0.75 0.018 0.030 l1 1.00 0.039 0 7 0 7 n80 80 nd 20 20 ne 20 20 cp 0.08 0.003
261/264 upsd34xx - part numbering part numbering table 185. ordering information scheme for other options, or for more information on any aspect of this device, please contact the st sales office nearest you. example: upsd 34 3 4 e v ? 40 u 6 t device type upsd = microcontroller psd family 34 = turbo plus core sram size 2 = 4kbyte 3 = 8kbyte main flash memory size 2 = 64kbyte 3 = 128kbyte 4 = 256kbyte ip mix e = ip mix: usb, i 2 c, spi, uart (2), irda, adc, supervisor, pca operating voltage blank = v cc = 4.5 to 5.5v v = v cc = 3.0 to 3.6v speed ?40 = 40mhz package t = 52-pin tqfp u = 80-pin tqfp temperature range 6 = ?40 to 85c shipping optio n tape & reel packing = t
upsd34xx - important notes 262/264 important notes the following sections desc ribe the limitations that apply to the upsd34xx devices. usb interrupts with idle mode description an interrupt generated by a usb related event does not bring the mcu out of idle mode for pro- cessing. impact on application idle mode cannot be used with usb. workaround none identified at this time. usb reset interrupt description when the mcu clock prescaler is set to a value other than f mcu = f osc (no division), a reset signal on the usb does not cause a usb interrupt to be generated. impact on application an mcu clock other than that equal to the frequen- cy of the oscillato r cannot be used. workaround the cpups field in the ccon0 register must be set to 000b (default after reset). the 3400 usb firmware examples set ccon0 register to 000b. usb reset description a usb reset does not rese t the usb sie's regis- ters. impact on application a usb reset does not rese t the usb sie's regis- ters as does a power-on or hardware reset. workaround when a usb reset is detected, the usb sie's reg- isters must be initialized appropriately by the fir- ware. the 3400 usb firmware examples clear usb sie?s if usb reset is detected. data toggle description the data toggle bit is read only. impact on application the in fifo data toggle bit is controlled exclusive- ly by the usb sie; therefore, it is not possible to change the state of the data toggle bit by firmware. workaround for cases where the data toggle bit must be reset, such as after a clear feature/stall request, send- ing the subsequent data on that endpoint twice re- sults in getting the data toggle bit back to the state that it should be. usb fifo accessibility description the usb fifo is only accessible by firmware and not by a jtag debugger. impact on application using a jtag debugger, it is not possible to view the usb fifo's contents in a memory dump win- dow. workaround none identified at this time. erroneous resend of data packet description when a data packet is sent the respective in fifo busy bit is not automatically cleared by the usb sie. this can cause a data packet to be errone- ously resent to the host in response to an in pid immediately after the first correct transmission of this data packet. impact on application since the data toggle in the retransmitted data packet is toggled from when the data was first sent, the host will treat this packet as valid. if the identified workaround is not implemented then this extra and unexpected data packet would result in a communication breakdown.
263/264 upsd34xx - important notes workaround in the usb isr, when an inx (x = the endpoint number of the in fifo) is detected, the in fifos respective busy bit should be unconditionally cleared. the 3400 usb firmware implements this workaround. in fifo pairing operation description fifo pairing is not available on in endpoints. sin- gle fifo buffering should be used instead. impact on application use single fifo buffering. workaround only use the single-fifo mode. the 3400 usb firmware implements this workaround. port 1 not 5-volt io tolerant description the port p1 is shared with the adc module and as a result port p1 is not 5v tolerant. impact on application 5v devices should not be connected to port p1. workaround peripherals or gpio that require 5-volt io toler- ance should be mapped to port 3 or port 4.
upsd34xx - revision history 264/264 revision history table 186. document revision history date version revision details 04-feb-2005 1.0 first edition 30-mar-2005 2.0 added one note in summary description, page 7 added two notes in usb interface, page 123 changed values in table 175., page 252 (turbo off column) added important notes, page 262 information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectro nics. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners ? 2005 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia ? belgium - brazil - canada - china ? czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of UPSD3423E-40T6T

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X